You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Richard Zschech <ri...@cqrdata.com> on 2002/04/29 14:58:30 UTC
Document level comments getNextSibling()
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: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org