my dog learned polymorphism*
The moose likes XML and Related Technologies and the fly likes Problem in getNodeValue() 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 "Problem in getNodeValue()" Watch "Problem in getNodeValue()" New topic
Author

Problem in getNodeValue()

mahadevan raja
Ranch Hand

Joined: Apr 11, 2001
Posts: 96
hi all,
i have an xml file,which has the following content
<?xml version="1.0"?>
<?xml-stylesheet href="ConvertXSL.xsl" type="text/xsl"?>
<movies xmlns="x-schema:Convert.xml" >
<movie>
<title>first title</title>
</movie>
</movies>
i have written a code in servlet in which i parse this document using a DOMParser just to get the number of nodes present in the whole document and the value of each node.
according to this
i get 3 child nodes
1.#text
2.movie->has 3 child nodes->#text,title & #text
3.#text
when i get the value of the element node i.e movie i get null ,fine
but the problem is i need the value of title->i.e i need first title to be printed.
i used the getNodeValue() method but i am not getting anything displayed.how do i do this.
can anybody help me.


SPECIALIST-WCSV5.1 Implementation.<br />SYSTEMS EXPERT-WAS4.0 Administration
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
let me try,
using the DOMParser, you can try extracting the child nodes of the title element and then you can get the child which is of the type TEXT_NODE and extract the value using getNodeValue()?

in this case i assume that the variable named node points to the title element.
let me know if it works..:-)
karthik.
mahadevan raja
Ranch Hand

Joined: Apr 11, 2001
Posts: 96
thank you karthik
ur code helped me a lot,there was a flaw in my program,now it is working,
thank you.
 
Don't get me started about those stupid light bulbs.
 
subject: Problem in getNodeValue()