What is the difference or similarity between SAX, DOM, JDOM?

What is the difference or similarity between SAX, DOM, JDOM?

I want to know what is the difference or similarity between SAX, DOM, JDOM and JAXP? All of them are APIs used for XML processing and SAX and DOM are inherently different in the way XML data is represented.

    Requires Free Membership to View

    When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to keep you informed on recent service-oriented architecture (SOA) and SOA-related topics such as integration, governance, Web services, Cloud and more.

    Hannah Smalltree, Editorial Director

    By submitting your registration information to SearchSOA.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchSOA.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

SAX uses an event callback mechanism requiring you to code methods to handle events thrown by the parser as it encounters different entities within the XML document.

DOM parses an XML document and returns an instance of org.w3c.dom.Document. This document object's tree must then be "walked" in order to process the different elements.

JDOM is an open source API, designed specifically for Java programmers, that represents an XML tree as Elements and Attributes. JDOM can interact with SAX or DOM. With JDOM, you construct an instance of a builder (org.jdom.input.SAXBuilder or org.jdom.input.DOMBuilder) and then invoke the build() method on the builder to construct a Document object from the input source (a File, an InputStream, a URL, etc.).

JAXP relies on factories to support different parser implementations (including SAX, DOM) or XSLT engines. This gives you the option of using a callback mechanism or a builder mechanism that generates a document object.

The specific parser technology that you use will be determined by the requirements of your application. If you need the entire document represented, you will most likely use DOM, JDOM or JAXP's builder implementation. If you only care about parts of the XML document and/or you only need to parse the document once, you might be better served using SAX or JAXP's SAX implementation.

 


For news, advice and other information about web services standards, click here.

This was first published in April 2002