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);
    //etc...

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

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.

Jim.
Received on Tuesday, 29 May 2001 20:27:42 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:48 GMT