SAX API Simple API for XML –SAX API Overview • The basic outline of the SAX parsing APIs is shown in Figure (on next Slide). To start the process, an instance of the SAXParserFactory c lass is used to generate an instance of the parser Simple API for XML –SAX API Introduction • The parser wraps a SAXReader object. Parser's parse() metho d invoked, the reader invokes one of several callback methods implemented in the application. Methods defined by interfaces ContentHandler, Error Handler, DTDHandler and EntityResolver. Simple API for XML –SAX API SAX – API Structure Simple API for XML –SAX API Summary SAXParserFactory • A SAXParserFactory obj ect creates an instance of the parser determined by the system property. Simple API for XML –SAX API Summary SAXParser • The SAXParser interfac e defines several kinds of parse() methods. In general, you pass an XML data source and a DefaultHandler objec t to the parser, which processes the XML and invokes appropriate methods of handler object. Simple API for XML –SAX API Summary SAXReader • The SAXParser wraps SAXReader. Using SAXParser's getXMLRe ader() so that you can configure it. It is the SAXReader that carries on the conversation with the SAX event handlers define by Programmer. Simple API for XML –SAX API Summary DefaultHandler • DefaultHandler imple ments(Wraps)the Cont entHandler, ErrorHandl er, DTDHandler, and EntityResolver inte rfaces (with null methods), so override only the those which are required. Simple API for XML –SAX API Summary ContentHandler • Methods such as startDocument, end Document, startEleme nt, and endElement are invoked when an XML tag is recognized. Simple API for XML –SAX API Summary ContentHandler • Interface also defines methods characters() a nd processingInstruction() which are invoked when the parser encounters the text in an XML element or an inline processing instruction, respectively.