This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How to get the value of the node


You have to take in account the fact that XML is CaSe-sensitive...

So write       NodeList nl = doc.getElementsByTagName("EXPIRE");

This should work a lot better...

Grtz,
Raimond

----- Original Message ----- 
From: "Cheun N Chong" <cnc99r@ecs.soton.ac.uk>
To: <XSL-List@mulberrytech.com>
Sent: Friday, May 12, 2000 1:29 PM
Subject: HELP: How to get the value of the node 



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



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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]