ar******@yahoo.com wrote:
The code below gets me a list of all the nodes within the node object
called xml_tags_root.
NodeList nl = xml_tags_root.getChildNodes();
The length of nodelist I get is double the number of actual elements!
This is because after every element node there is text node which is (I
think) the whitespace in the XML document.
Is there a way to get only the element nodes?
Depending on the parser and the API you are using there might be ways to
only access the elements nodes, either by having white space text nodes
ignored during parsing and not included in the DOM tree at all or by
using a selection method later, for instance XPath, to access only
element nodes.
But as you have not provided any details on which parser/API you are
using it is hard to tell. I guess you are using Java and the W3C DOM, in
Java 1.5 you could use XPath.
--
Martin Honnen
http://JavaScript.FAQTs.com/