aspose file tools*
The moose likes XML and Related Technologies and the fly likes XML Parsing using SAX, DOM and JAXP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Parsing using SAX, DOM and JAXP" Watch "XML Parsing using SAX, DOM and JAXP" New topic
Author

XML Parsing using SAX, DOM and JAXP

Naren Chivukula
Ranch Hand

Joined: Feb 03, 2004
Posts: 577

Hi,

I want to parse my XML file in either of these techniques i,e.. SAX, DOM or JAXP. Please tell me which one is the best suited at what situations.

Thanks and Regards,
Narendranath


Cheers,
Naren
(OCEEJBD6, SCWCD5, SCDJWS, SCJP1.4 and Oracle SQL 1Z0-051)
Amit K Srivastava
Greenhorn

Joined: May 16, 2006
Posts: 23
There are basically three major approaches/ implementations through which which you can process XML: SAX, DOM & JAXB
SAX and DOM are generic XML parsers
They will parse any well-structured XML
JAXB creates a parser that is specific to your DTD
A JAXB parser will parse only valid XML (as defined by your DTD)
DOM and JAXB both produce a tree in memory
DOM produces a generic tree; everything is a Node
JAXB produces a tree of Objects with names and attributes as described by your DTD.

JAXP The Java API for XML Processing (JAXP) enables applications to parse and transform XML documents independent of a particular XML processing implementation.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
SAX is faster than DOM, should we always use SAX on huge XMLs?.
JAXB Overview
Kaise a.Zakkar
Ranch Hand

Joined: Oct 20, 2003
Posts: 47
HI Naren
if you are a new incomer to the XML parsing world , i think that DOM API is
more suitable and easy to use than SAX ,and it took from you nothing more
than creating the Factory object and then invoke a list of methodes to go
through the elements of the XML document
but the problem with DOM is that it use more memory resources than SAX
and it takes more time for paring than SAX ,but if your application hasnt that
much restriction about time and memory , DOM must be your choice
Good luck
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: XML Parsing using SAX, DOM and JAXP