This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes How to read the contents of xml file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to read the contents of xml file" Watch "How to read the contents of xml file" New topic
Author

How to read the contents of xml file

sai prasanna
Ranch Hand

Joined: May 02, 2005
Posts: 167
Hi all,

How to read an xml file and write to an xml file using DOM parser. My xml file is as below i should read <CUSTOMERS> into one xml file and </USERS> into another xml file along with tags.

<CUSTOMERS>
<CUSTOMER>
<CUSTOMER_ID>BRELLINGER</CUSTOMER_ID>
<STATUS>SUCCESS</STATUS>
<ERROR_CODE></ERROR_CODE>
</CUSTOMER>
<CUSTOMER>
------------
</CUSTOMER>
</CUSTOMERS>
<USERS>
<USER>
<USER_ID></USER_ID>
<CUSTOMER_ID>BRELLINGER</CUSTOMER_ID>
<STATUS>SUCCESS</STATUS>
<ERROR_CODE></ERROR_CODE>
<ERROR_MSG></ERROR_MSG>
</USER>
<USER>
------
------
</USER>
</USERS>

Iam new to xml, anybody please help
Thanks In Advance,
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18114
    
    8

New to XML and don't know anything about how to process it in Java? Then reading a tutorial (or a book) should be the first thing you do. Here is a link to a tutorial.
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

The book Processing XML with Java by Elliotte Rusty Harold is a good intro book, covering the various aspects of XML. There is a free online version available to read. There some good samples in it on how to do exactly what you are asking. After reading it, you can then look at other books that get in more details about the various topics (SAX, DOM, XSLT, etc).
[ January 31, 2007: Message edited by: Mark Vedder ]
sai prasanna
Ranch Hand

Joined: May 02, 2005
Posts: 167
Thanks for the reply
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to read the contents of xml file
 
Similar Threads
Marshalling with JAXB- No Parent tag
how to map column if there is no relationship??
It's boring, XSLT ...
OpenJPA Foreign Key
how to read Processing instruction ;Jax-rpc