• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in getNodeValue()

 
mahadevan raja
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you karthik
ur code helped me a lot,there was a flaw in my program,now it is working,
thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic