The simple filter application contains the building blocks of almost all SAX applications, including:
ISAXXMLReader
interface. SAXXMLReader
consumes the XML and throws events to the handlers that you set for the reader. This example creates an instance of SAXXMLReader
, and then sets a ContentHandler
and an ErrorHandler
for receiving events from the reader.ContentHandlerImpl
class implements the IVBSAXContentHandler
interface. This application highlights the main events received by the ContentHandler
, including startDocument
, endDocument
, startElement
, endElement
, and characters
.ContentHandlerImpl
class also implements the IVBSAXErrorHandler
interface. At this time, MSXML supports the fatalError
method only.This application consists of two main parts.
SAXXMLReader
; creates an instance of the class implementing the IVBSAXContentHandler
and IVBSAXErrorHandler
interfaces; and then sets the contentHandler
and errorHandler
properties of the reader to point to the class. Pressing Parse also sets the filter criteria in the content handler, sets the input for the reader, and starts the parse operation.IVBSAXContentHandler
and IVBSAXErrorHandler
interfaces. When parsing begins, the reader throws a series of events that are received by an instance of the ContentHandlerImpl
class. For example, for each element in a document, the reader throws the startElement
, characters
, and endElement
events. To conditionally output content passed by these events, you add code to the methods in the ContentHandlerImpl
class. The ContentHandlerImpl
class also implements the IVBSAXErrorHandler
interface, which catches any error events thrown by the reader. At this time, the reader only invokes the fatalError
method.The simple filter application uses the sample XML file, books.xml.
Application Form | IMXWriter Interface | MXXMLWriter CoClass | ISAXContentHandler Interface | ISAXErrorHandler Interface | Sample XML File (books.xml)