[vtkusers] XMLDataParser for generic xml parsing
Gerrick Bivins
gbivins at objectreservoir.com
Tue Aug 19 13:38:30 EDT 2008
Hi All,
Can I use vtkXMLDataParser to parse any xml file. It seems like all the
calls are there in the API but when I attempt to read one of my own xml
files, the GetCharacterData() for nested components is empty.
Here is the sample function:
protected void parseXMLComponentsDefinitionFile(String xmlFileName,
java.util.List<String>
filteredComponents)
{
vtkXMLDataParser parser = new vtkXMLDataParser();
parser.SetFileName(xmlFileName);
if( parser.Parse() == 1)
{
vtkXMLDataElement root = parser.GetRootElement();
//vtkXMLDataElement components =
root.LookupElementWithName("components");
int numberOfComponents = root.GetNumberOfNestedElements();
for(int i = 0; i < numberOfComponents; ++i)
{
vtkXMLDataElement component = root.GetNestedElement(i);
vtkXMLDataElement componentID = component.GetNestedElement(0);
vtkXMLDataElement componentName = component.GetNestedElement(1);
vtkXMLDataElement componentType = component.GetNestedElement(2);
String id = componentID.GetCharacterData();//<== this is empty
System.out.println(id);
if( filteredComponents.contains(id))
{
String [] componentInfo = {componentName.GetCharacterData(),
componentType.GetCharacterData()};
componentsMap.put(id, componentInfo);
}
}
}
else
{
}
}
--
View this message in context: http://www.nabble.com/XMLDataParser-for-generic-xml-parsing-tp19055150p19055150.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list