File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes text node value null... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "text node value null..." Watch "text node value null..." New topic

text node value null...

mahesh jhamtani

Joined: Jan 12, 2001
Posts: 11
I am getting value of text node as NULL.(which is not null)
Can you tell me what is wrong in this code...

Element el = doc.getDocumentElement();
NodeList nl = el.getElementsByTagName("Name");
for (int i=0; i<nl.getLength(); i++)
if(nl.item(i).getNextSibling().getNodeType()== Node.TEXT_NODE)
{Text textNode = (Text)(nl.item(i).getNextSibling());
String text = textNode.getData();
if ((text != null) && text.length() > 0)
System.out.println("value of node is " + text); }
I agree. Here's the link:
subject: text node value null...
It's not a secret anymore!