- From: Barbara Samson <bsamson@cisco.com>
- Date: Tue, 29 May 2001 10:17:15 -0700
- To: "Tom Leuntjens" <tom.leuntjens@bricsnet.com>
- Cc: <www-dom@w3.org>
Hi Tom: Two things: 1. Remove the slash from the opening </companies>. 2. If you're working with Java, then take a look at www.jdom.org. You will have to write your own code to process the XML, but it's pretty easy. Regards, Barbara Samson At 03:55 PM 5/29/2001 +0200, Tom Leuntjens wrote: >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 13:19:31 UTC