- From: Tom Leuntjens <tom.leuntjens@bricsnet.com>
- Date: Tue, 29 May 2001 15:55:32 +0200
- To: <www-dom@w3.org>
Hi All,
Kinda new to all of the xml things and didn't not find any proper examples
I'm looking for simple code examples that would process the following XML(if
that is valid?!)
I though if you had something like
</companies>
<company>
<name> Bricsnet NV </name>
<phone> 092440100 </phone>
<fax> 092440101 </fax>
<email> tom.leuntjens@bricsnet.be </email>
<products>
<product>
<productname> wood </productname>
<url> wood.com </url>
</product>
product>
<productname> wmetal </productname>
<url> wmetal.com </url>
</product>
</products>
</company>
<company>
<name> Bricsnet NV </name>
<phone> 092440100 </phone>
<fax> 092440101 </fax>
<email> tom.leuntjens@bricsnet.be </email>
<products>
<product>
<productname> wood </productname>
<url> wood.com </url>
</product>
</products>
</company>
</companies>
you would be able to do something like this
(pseudo-code)
and that is the kind of thing i was looking for
for (companies) {
show name
show phone
show fax
show emial
for (products) {
show productname
show url
}
}
and preferably based on this kind of code (thats the only thing i found so
far)
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse("http://127.0.0.1:81/company.xml");
NodeList name = doc.getElementsByTagName("name");
for (int i =0; i < name.getLength(); i++) {
out.print(name.item(i).getFirstChild().getNodeValue() + "<br>");
}
so a push in the right direction would be appreciated.
Regards,
Tom
Received on Tuesday, 29 May 2001 09:56:40 UTC