[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

HELP: How to get the value of the node

Subject: HELP: How to get the value of the node
From: Cheun N Chong <cnc99r@xxxxxxxxxxxxxxx>
Date: Fri, 12 May 2000 12:29:15 +0100 (BST)
xerces get value
Hi all,

	Perhaps I have really repeated my question several times and I am
terribly sorry about that. I am quite frustrated here. I have the
following codes:

=============== THE XML CODES =======================
<BOUGHTSTUFF>

<STUFF>
      <TYPE>milk</TYPE>
      <EXPIRE>6 may 2000</EXPIRE>
</STUFF>

<STUFF>
      <TYPE>pork chop</TYPE>
      <EXPIRE>7 may 2001</EXPIRE>
</STUFF>

</BOUGHTSTUFF>      


=============== THE JAVA CODES ======================
      fileinput = new FileInputStream("stuff.xml");
      xmlinput = new InputSource(fileinput);

      // Use a DOMParser from Xerces so we get a complete DOM from the
document
      DOMParser parser = new DOMParser();
      parser.parse(xmlinput);

      // Get the document and the node list of the required tag name
      Document doc = parser.getDocument();
      NodeList nl = doc.getElementsByTagName("Expire");
      out.println(nl.getLength());
      Node n = nl.item(0);
      String value = nl.item(0).getNodeValue();
      out.println(value);
======================================================

	I want to get the node value of Expire for milk. However when I
tried that code, it print out "null" but when I change the
getNodeValue() to getNodeName(), it can print out the "Expire". Is there
any wrong codes. I really need your expertise.

	Thousand thanks. Wish you all the best.

Best regards,
Cheun Ngen CHONG





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.