wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes Node.getNodeValue() is not parsing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Node.getNodeValue() is not parsing "" Watch "Node.getNodeValue() is not parsing "" New topic
Author

Node.getNodeValue() is not parsing "

Shan Karawita
Ranch Hand

Joined: Oct 13, 2000
Posts: 83
Hi,
I'm trying to parse a xml document which is going to have a entity references such as & quot; & nbsp; etc.. as Node values.
But when I try to get the node value with the getNodeValue() method of the Node object, it's not giving me the complete content.
Ex :

[Note : I have not typed the entity reference charectors properly here since it's converting it to it's representation.]
Please help.
Thanks in advance.
[ September 21, 2003: Message edited by: Shan Karawita ]
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
I wonder how createXmlDocument(java.lang.String documentURI, boolean doValidate) didn't throw an exception already when you tried to feed the document itself as a string to it? (unless you just typed a quick example)


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Shan Karawita
Ranch Hand

Joined: Oct 13, 2000
Posts: 83
You are right. As you mentioned I have typed a quick example here. It should have been a InputStream.
Has it happend to anyone ....? Please help ... I'm really stucked.
[ September 21, 2003: Message edited by: Shan Karawita ]
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
Here you are assuming that "C" has only one child ( ie the Text that you typed). It is not the case actually. Even though it appears as if there is only one child of type TEXT, it might have multiple such TEXT nodes.
So it's recommended that you always run through all the child nodes of type TEXT and append the node value. Here i have not checked for the node type, since you dont have any other child elements.
Shan Karawita
Ranch Hand

Joined: Oct 13, 2000
Posts: 83
Thank you so much Karthik..... problem is halfway solved.
But it's printing me "This is my null quote null"
Any idea how to overcome this. ?
Thanks in advance.
Shan Karawita
Ranch Hand

Joined: Oct 13, 2000
Posts: 83
Thanks Karthik , I managed to make the change to work.
Here it is.

This really works fine.
Thank you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Node.getNodeValue() is not parsing "