File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes parsing data in xml document 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 "parsing data in xml document" Watch "parsing data in xml document" New topic

parsing data in xml document

Prasath Thirumoorthy
Ranch Hand

Joined: Jul 23, 2004
Posts: 65
Hi Friends,
I hope u all fine.

In how many ways we can parse the data from the xml document ?

do let me know the answer for this...

Thanks & Regards,


William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
You should start by reading this Sun tutorial on working with XML in Java.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi Prasath,

get a good book (Safari online book shelf is not bad). To give you an idea:
You have 4 possibilities to work with XML:

1) Treat it as a text string (including regular expressions) -- not recommended
2) Use a SAX parser. J2SE1.4 has one built in. The parser will fire one event for everything it encounters in the XML and you need to provide a class that handles the events
3) Use a PULL parser (like kXML). Works a little like SAX, the main difference is that you ask for the next piece instead of getting it thrown at you.Works very well also on J2ME (Phone, PDA)
4) Use a DOM parser. J2SE 1.4 has one build in. The parser builds the XML Document as a (in memory) tree and you can move around, query and update it

Good luck with your studies.
:-) stw
I agree. Here's the link:
subject: parsing data in xml document
It's not a secret anymore!