XML traversal in levelorder



Hi,

I would like to traverse a XML document in levelorder. My next steps
depend on different nodes and their levels.

What I did by now was to set up a XmlStreamEventReader to easily
choose the next steps for each node and node-type:

m_in = new FileInputStream(file);
m_factory = XMLInputFactory.newInstance();
m_parser =
m_factory.createXMLEventReader(m_in);

// parse events
while(this.m_parser.hasNext())
{
XMLEvent event = m_parser.nextEvent();

switch(event.getEventType())
{
case
XMLStreamConstants.START_DOCUMENT:
break;

case XMLStreamConstants.START_ELEMENT:
StartElement startElement = event.asStartElement();

// common mib files
if(startElement.getName().toString()=="Common")
newCommonInstance(startElement);

....

The XmlStreamEventReader traverses the XML file in preorder.

And because of my XML file only consists of nodes with attributes (so
there's no node-value only attributes an their values), working with a
DOM is pretty strange. As soon as I walk through the nodes my root has
i.e. 5 instead of actually 2 children:

root
#text
node1
#text
node2
#text

How do I get rid of the "#text"-blanks or what should I do to
correctly traverse in levelorder?
.



Relevant Pages

  • XML traversal in levelorder
    ... I would like to traverse a XML document in levelorder. ... The XmlStreamEventReader traverses the XML file in preorder. ...
    (comp.lang.java.programmer)
  • Re: Traversing Visio vdx with XPath library in c#
    ... I'm trying to take a Visio document saved as a vdx (xml) that appears to be ... I have sample xml files ... traverse those, the nodes and their values are found. ... Is there something different/unusual about a Visio vdx file that cannot be ...
    (microsoft.public.visio.developer)
  • Re: XML Nodes conversion to Hashtable
    ... Actaully i need to traverse the XML Nodes again and again and want to pick ... the hash table, otherwise a hash table will not work as you can't iterate ... For this i need to Load the XML document into the XMLDocument ...
    (microsoft.public.dotnet.xml)