Hi,

Im having trouble treversing all the child nodes from the Document object.
Usually when treversing the child nodes from an Element for example I go:


Node node = element.getFirstChild(); while(node != null) { // do some processing

  node = node.getNextSibling();
}


But when I do this starting from a Document with comments and a root like:

<!-- comment 1 -->
<!-- comment 2 -->
<root/>

the nextSibling() method of the <!-- comment 1 --> node returns null.

The following method of iteraton also dosent work because nodeList.getLength() returns 1.

NodeList nodeList = document.getChildNodes();
for(int i=0; i<nodeList.getLength(); i++) {
   // do some processing
}

Is this whats supposed to happen?

If I print the DOM tree with a identity JAXP transformer the whole tree comes out so their obviously there Im just not accessing them correctly.
How does it treverse the documents children?


What am I doing wrong?

Thanks in advance,
From Richard.


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to