- From: Dimitris Dimitriadis <dimitris.dimitriadis@improve.se>
- Date: Tue, 29 May 2001 15:41:35 +0200
- To: "'Tom Leuntjens'" <tom.leuntjens@bricsnet.com>, www-dom-ts@w3.org
Hi Tom This mailing list is primarily devoted to developing the DOM Test Suite. I think it's more appropriate to pose your question to xml-dev@lists.xml.org and/or www-dom@w3.org. One quick tis is to get hold of the <products/> element in your source file and extract it's children, similar to what you've done in your code snippet with message (instead of looking for the document's children named message, you'd have to look for elements called products, then look at it's repsective children). I'm sure you'll get valuable feedback from the mailinglists indicated above. Kind regards, /Dimitris -----Ursprungligt meddelande----- Från: Tom Leuntjens [mailto:tom.leuntjens@bricsnet.com] Skickat: den 29 maj 2001 15:23 Till: www-dom-ts@w3.org Ämne: need guidance Hi All, I don't even know if this is the place I can be to get this kind of help. Sorry if it't not. Got a task of having to import XML data to oracle. the importing is not the problem if I can read everything (JSP/JAVA) I'm happy. All i need for starters is some sample code. How would one start when you have XML simular to this. (see bottom) So I have lots of companies and those companies have their data (name,phone, ....) + 1 or more products with their date (name, url, material) and can somebody point me the right way how I can retrieve these using DOM. So far I have only been able to retrieve something simple like this <messages> <message> First in line !</message> <message> sECOND IN LINE !</message> <message> LAST IN LINE</message> </messages> with the simple code DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse("http://127.0.0.1:81/company.xml"); NodeList nl = doc.getElementsByTagName("message"); for (int i =0; i < nl.getLength(); i++) { out.print(nl.item(i).getFirstChild().getNodeValue() + "<br>"); } Thanx in advance Tom What my xml file would look like, so i need to retreive this kind of data <companies> <company> <name> Blabla </name> <phone> 092440100 </phone> <fax> 092440101 </fax> <email> tom.leuntjens@bricsnet.be </email> <products> <product> <productname> wood thingies </productname> <producturl> wood.com </producturl> </product> <product> <productname> metalthingies </productname> <producturl> wood.com </producturl> </product> </products> </company> <company> <name> Blabla2 </name> <phone> 092440100 </phone> <fax> 092440101 </fax> <email> tom.leuntjens@bricsnet.be </email> <products> <product> <productname> wood thingies </productname> <producturl> wood.com </producturl> </product> <product> <productname> metalthingies </productname> <producturl> wood.com </producturl> </product> </products> </company> </companies>
Received on Tuesday, 29 May 2001 09:42:01 UTC