JAXP - Java API for XML processing - is an API provided in Java SE that is used for parsing XML documents using Java programming language. JAXP supports XML parser standards - Simple API for XML Parsing (SAX), Document Object Model (DOM) and Streaming API for XML (StAX).
JAXP also supports 'Extensible Stylesheet Language Transformation (XSTL)' that can be used to convert the XML data to other XML documents as well as other formats such as HTML.
Simple API for XML (SAX) parser processes the XML document element-by-element. SAX parser is event driven and uses serial-access mechanism to process the XML document.
javax.xml.parsers package in Java SE provides the SAX specific APIs.
Document Object Model (DOM) parser processes an XML document into a tree structure of objects and stores the entire object model to memory. Once the object model is stored in memory, it can be traversed, accessed and manipulated by a Java program.
javax.xml.parsers package in Java SE provides the DOM specific APIs.
Streaming API for XML (StAX) parser processes an XML document element-by-element and is based on Java streaming.
javax.xml.stream package in Java SE provides the StAX specific APIs.
StAX has a simpler programming model compaed to SAX, and is more memory efficient compared to DOM.
The JAXP API provides the following classes and interfaces for processing XML documents using a SAX parser.
SAXParserFactory - SAXParserFactory creates an instance of SAXParser.
SAXParser - SAXParser interface defines overloaded parse() methods. Generally you pass the source XML document and an handler object that implements the interface DefaultHandler to the parse() method.
SAXReader - SAXReader is wrapped by the SAXParser. SAXReader is used for readinmg the XML document and communicating with the SAX event handlers.
ContentHandler - ContentHandler interface defines methods such as startDocument, endDocument, startElement, endElement which are invoked when an XML element is processed.
ErrorHandler - ErrorHandler interface defines the methods error(), fatalError() and warning() which are invoked when the parser encounters error while parsing the XML document.
DTDHandler - DTDHandler defines methods that are used for processing a DTD document.
DefaultHandler - DefaultHandler class implements the ContentHandler, ErrorHandler, DTDHandler, and EntityResolver interfaces. You generally extend DefaultHandler and override only the appropriate methods.