- From: Tom Leuntjens <tom.leuntjens@bricsnet.com>
- Date: Tue, 29 May 2001 15:22:46 +0200
- To: <www-dom-ts@w3.org>
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:23:58 UTC