• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

XML Parsing using SAX, DOM and JAXP

 
Ranch Hand
Posts: 577
Tomcat Server Notepad Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SAX is faster than DOM, should we always use SAX on huge XMLs?.
JAXB Overview
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic