Entering content frame

Process documentation Using SAX Parser Locate the document in its SAP Library structure

Purpose

Different issues about how to use SAX Parser for processing XML documents will be explained.

Process Flow

In order 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, which extends org.xml.sax.helpers.DefaultHandler. This class – DefaultHandler is a class, which has default, empty, implementations of all the methods of the ContentHandler interface (and also - ErrorHandler, DTDHandler), and implements all these interfaces itself. So if you need to be notified when an element is starting, you just need to extend this class and overwrite the startElement() method.

Here are the two main SAX Parser classes:

·        javax.xml.parsers.SAXParserFactory

·        javax.xml.parsers.SAXParser

 

Leaving content frame