Hi,

Im trying to get the value of an XML node, I have the following xml
document.

<root xmlns:dt="urn:schemas-microsoft-com:datatypes">
<title>aaaaaaaaaaaa</title>
        <date>19/05/2002 11:34:17</date>
        <description>sfsdfsdf</description>
        <category>1</category>
</root>

I want to get the value of <title> in this case aaaaaaaaaaa im using the
following java code


String sOut;
DocumentBuilderFactory dbf =    DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(inStream);

// get the root element
Element eRoot = doc.getDocumentElement();
// get the children
NodeList nList = eRoot.getChildNodes();

try {

        sOut = nList.item(0).getNodeName() + " : " +
nList.item(0).getNodeValue();

} catch (NullPointerException npe) {

        sOut = "Unable to get node data " + npe;
}

The node name is being correctly returned as title but the node value is
being returned as null.  I think i read in the docs somewhere that the node
value will return null if the node is an element ?

Can anyone help this is driving me mad : )

Nic

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to