- From: James Melton <James.Melton@morganstanley.com>
- Date: Tue, 29 May 2001 15:03:49 -0400 (EDT)
- 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 UTC