Q
Problem solve Get help with specific problems with your technologies, process and projects.

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.

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 last published in April 2002

Dig Deeper on Development implications of microservices architecture

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide.com

SearchWinDevelopment

DevOpsAgenda

Close