Text nodes and element nodes query

A

asd

Hi all,

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?

Please advice.

thanks,
ASD
 
A

asd

Thanks for your reply.

Can I get a nodelist which consists of only Element Nodes but no text
nodes out of all the child elements of a node?

getElementsByTagname() will be used when one is aware of the name of
the tag in advance, right?

regards,

asd
 
A

Arnaud Berger

Hi,

See getNodeType() in class org.w3c.dom.Node, and various possible static
values :

e.g Node.ELEMENT_NODE, Node.TEXT_NODE ....

Regards,

Arnaud
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,247
Members
46,844
Latest member
JudyGvh32

Latest Threads

Top