This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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); }
Consider Paul's rocket mass heater.
subject: text node value null...
Similar Threads
Parsing XML doc
xml JAVA
Parsing XML with JAXP
How do I detect text wiithin the spantags
getNodeValue() returns null