wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes xml and jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xml and jsp" Watch "xml and jsp" New topic
Author

xml and jsp

Sunesh Kumar
Ranch Hand

Joined: Oct 17, 2005
Posts: 89
Hi Friends,

I am developing an application in which i have to read an xml, which is created by the data in all the tables in the database.

Now i have to read that xml and have to insert into databse when ever required.

My problem is that

NodeList orders = ordersRoot.getElementsByTagName("order");
NodeList products = ordersRoot.getElementsByTagName("product");
....so on

where order and product are tables..how can i give like this directly as the tables may vary..then how can i read and insert

can any one please suggest me...


Thanks & Regards<br />Sunesh Kumar Baachu
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

There appears to be no real JSP component to this question so I have moved it to the XML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

So you don't know what element name you will be looking for? Then you would just have to read the elements and find out what their names are. I will give you a link to a DOM tutorial:

http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/index.html

And if you google for "java dom tutorial" or "java xml tutorial" you will find more similar tutorials.
Sunesh Kumar
Ranch Hand

Joined: Oct 17, 2005
Posts: 89
Hi Paul,

Can you please guide me with an example...

Bye
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41874
    
  63
There are examples of how to read an XML file with either DOM or SAX here.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xml and jsp