W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

Re: guidance needed

From: James Melton <James.Melton@morganstanley.com>
Date: Tue, 29 May 2001 15:03:49 -0400 (EDT)
Message-ID: <3B13F27C.518AF6B1@morganstanley.com>
To: Joseph Kesselman <keshlam@us.ibm.com>
Cc: Barbara Samson <bsamson@cisco.com>, Tom Leuntjens <tom.leuntjens@bricsnet.com>, www-dom@w3.org
Joe: I agree with your assessment, and understand your point of view.
The problem is that Tom didn't really get an answer, which may by itself
be reason for him to start looking elsewhere.

Tom: Your code looks pretty good. The outermost loop though should be
looking for the "company" nodelist:
  NodeList name = doc.getElementsByTagName("company");

Then you get each of the elements inside that you want:
  for (i=0; i<name.length(); i++)
    Node company = NodeList.item(i);
    Node name = company.getElementsByTagName("name").item(1);
    Node phone = company.getElementsByTagName("phone").item(1);

    out.print(name.getFirstChild().getNodeValue() + "<br>");
    out.print(phone.getFirstChild().getNodeValue() + "<br>");

Disclaimer: This is very off the cuff code meant only to show that you
iterate over "company" elements rather than "name" elements. It may not
work exactly as coded.

Received on Tuesday, 29 May 2001 20:27:42 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:08 UTC