xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheun N Chong <cnc...@ecs.soton.ac.uk>
Subject HELP: How to get the value of the node
Date Fri, 12 May 2000 11:49:12 GMT

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 =======================

      <EXPIRE>6 may 2000</EXPIRE>

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


=============== 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
      DOMParser parser = new DOMParser();

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

	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

View raw message