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.
Dig Deeper on Development implications of microservices architecture
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.