ISAXXMLReader Interface

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - SAX2 Reference

ISAXXMLReader Interface

The ISAXXMLReader/IVBSAXXMLReader interface allows an application to set and query features and properties in Microsoft® XML Core Services (MSXML) 5.0 for Microsoft Office, register event handling for document processing, and initiate a document parse. MSXML provides the following CoClass that implements this interface.

SAXXMLReader50
The version-dependent CoClass ties the application to msxml5.dll.

(CLSID_SAXXMLReader50: 88d969c7-f192-11d4-a65f-0040963251e5)

With MSXML 4.0 and later, you can throw SAX events from a DOMDocument object by specifying the DOMDocument object as the input parameter for the parse method. For more information, see Convert DOM to SAX.

Controlling Reader Behavior

You can use the following methods to observe and control the behavior of the reader:

getFeature
Allows an application to ask the reader if it supports a feature.
putFeature
Allows an application to request that the reader turn a feature on or off.

Supported Features and Properties

The Microsoft COM/Visual Basic® implementation of SAX2 supports the following features (for example, a property whose value is Boolean).

  • "exhaustive-errors"
  • "http://xml.org/sax/features/external-general-entities"
  • "http://xml.org/sax/features/external-parameter-entities"
  • "http://xml.org/sax/features/lexical-handler/parameter-entities"
  • "http://xml.org/sax/features/namespaces"
  • "http://xml.org/sax/features/namespace-prefixes"
  • "preserve-system-identifiers"
  • "schema-validation"
  • "server-http-request"
[Visual Basic]

The reader recognizes the "http://xml.org/sax/features/string-interning" and "schema-validation" features. However, you cannot set these features in the current SAX2 implementation.

The reader also provides methods (getProperty, putProperty) for getting and setting these properties.

  • "http://xml.org/sax/properties/lexical-handler"
  • "http://xml.org/sax/properties/declaration-handler"
  • "http://xml.org/sax/properties/dom-node"
  • "http://xml.org/sax/properties/xml-string"
  • "charset"
  • "schemas"
  • "schema-declaration-handler"
  • "xmldecl-encoding"
  • "xmldecl-version"
  • "xmldecl-standalone"

Methods

getFeature Returns the Boolean value of a feature.
putFeature Sets the value of a feature.
getProperty Returns the value of a property (as a string), for any qualified Uniform Resource Identifier (URI).
putProperty Sets the value of a property.
parse Parses an XML document or a DOMDocument object.
parseURL Parses an XML document from a system identifier.

[Visual Basic]

The IVBSAXXMLReader interface is implemented in the Simple API for XML (SAX2) applications to manage and execute the parsing of an XML document.

Creating an Instance of the Reader

Typically, you create an instance of the reader in the Main form of a Visual Basic application. For example, first you declare a variable for holding a reference to the IVBSAXXMLReader50 interface. You then create an instance of the reader and assign the interface to the object variable as follows:

    Dim reader As SAXXMLReader50
    Set reader = New SAXXMLReader50

Creating an Instance of a Handler

After you create an instance of the reader, you can create an instance of a ContentHandler or ErrorHandler, and then set them as properties of the reader object using the contentHandler and errorHandler properties.

The following code sample declares variables for the ContentHandler and ErrorHandler implementations, creates instances of these two handlers, and registers these handlers with the reader object by defining them as properties of the reader.

    Dim reader As SAXXMLReader50
    Dim contentHandler As ContentHandlerImpl
    Dim errorHandler As ErrorHandlerImpl
    
    Set reader = New SAXXMLReader50
    Set contentHandler = New ContentHandlerImpl
    Set errorHandler = New ErrorHandlerImpl
    Set reader.contentHandler = contentHandler
    Set reader.errorHandler = errorHandler

Properties

baseURL Sets the base URL for the current document.
contentHandler Sets the current ContentHandler.
dtdHandler Sets the current DTDHandler.
entityResolver Sets the current EntityResolver.
errorHandler Registers or returns the current ErrorHandler.
secureBaseURL Sets the secure base URL for the document.

[C/C++]

Registering Handlers

An application can set and query features in the reader, register event handlers for document processing, and initiate a document parse. With this COM/C++ implementation of SAX2, the reader can use the following methods to register the corresponding handlers:

putContentHandler
Registers a ContentHandler.
putDTDHandler
Registers a DTDHandler.
putErrorHandler
Registers an ErrorHandler.

Methods

In addition to the preceding methods, the following also apply to the ISAXXMLReader interface.

getBaseURL Returns the base URL for the document.
putBaseURL Sets the base URL for the document.
getContentHandler Returns the current ContentHandler.
putContentHandler Allows an application to register a ContentHandler.
getDTDHandler Returns the current DTDHandler.
putDTDHandler Allows an application to register a DTDHandler.
getEntityResolver Returns the current EntityResolver.
putEntityResolver Allows an application to register an EntityResolver.
getErrorHandler Returns the current ErrorHandler.
putErrorHandler Allows an application to register an ErrorHandler.
getSecureBaseURL Returns the secure base URL for the document.
putSecureBaseURL Sets the secure base URL for the document.

Versioning

MSXML 3.0 and later

Requirements

Implementation: msxml5.dll, msxml2.lib

[C/C++]

Header and LIB files: msxml2.h, msxml2.lib

Version 5.0 Dependent ProgID: SAXXMLReader50

Version 5.0 Dependent CLSID: 88d969c7-f192-11d4-a65f-0040963251e5

To view reference information for Visual Basic or C/C++ only, click the Language Filter button Language Filter in the upper-left corner of the page.