File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem in getNodeValue()" Watch "Problem in getNodeValue()" New topic

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" >
<title>first title</title>
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>has 3 child nodes->#text,title & #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 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..:-)
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.
I agree. Here's the link:
subject: Problem in getNodeValue()
It's not a secret anymore!