[vtkusers] XMLDataParser for generic xml parsing

David E DeMarle dave.demarle at kitware.com
Tue Aug 19 13:52:21 EDT 2008


Hi Gerrick,

Try calling parser->SetIgnoreCharacterData(0).

The original vtk formats don't let the parser read the character data. The
potentially large data stored there is instead read elsewhere, much more
quickly and with much less memory overhead.

I added the Ignore flag a while back for a new reader which does get the
data from the parser.

cheers,
Dave DeMarle


On Tue, Aug 19, 2008 at 1:38 PM, Gerrick Bivins <gbivins at objectreservoir.com
> wrote:

>
> 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.
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080819/0fa49c54/attachment.htm>


More information about the vtkusers mailing list