• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Problem in getNodeValue()

 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic