Show TOC Start of Content Area

Function documentation Processing XML Using SAX Locate the document in its SAP Library structure

Use

SAX uses the callback approach to parse an XML document. Therefore, greater efficiency is achieved when parsing large XML documents.

The most important methods and interfaces that are used when processing an XML using SAX are:

·        org.xml.sax.ContentHandler

·        org.xml.sax.Attributes

Activities

To process an XML document using SAX, you have to take the SAXParser from a SAXParserFactory and supply it with a source document and an instance of a class that extends org.xml.sax.helpers.DefaultHandler. This class – DefaultHandler, has default, empty implementations of all methods of the ContentHandler, ErrorHandler, and DTDHandler interface and implements these interfaces itself. So, if you need to be notified when an element is starting, you just have to extend this class and overwrite the startElement() method.

These are the main SAX Parser classes:

·        javax.xml.parsers.SAXParserFactory

·        javax.xml.parsers.SAXParser

 

End of Content Area