ISAXXMLReader Interface
The ISAXXMLReader/IVBSAXXMLReader interface allows an application to set and query features and properties in Microsoft® XML Core Services (MSXML), register event handling for document processing, and initiate a document parse. MSXML provides the following CoClass that implements this interface.
- SAXXMLReader40
- The version-dependent CoClass ties the application to msxml4.dll.
(CLSID_SAXXMLReader40: 88d969c7-f192-11d4-a65f-0040963251e5)
With MSXML 4.0, you can now 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 IVBSAXXMLReader or IVBSAXXMLReader30 interface. You then create an instance of the reader and assign the interface to the object variable as follows:
Dim reader As SAXXMLReader40
Set reader = New SAXXMLReader40
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 SAXXMLReader40
Dim contentHandler As ContentHandlerImpl
Dim errorHandler As ErrorHandlerImpl
Set reader = New SAXXMLReader40
Set contentHandler = New ContentHandlerImpl
Set errorHandler = New ErrorHandlerImpl
Set reader.contentHandler = contentHandler
Set reader.errorHandler = errorHandler
Properties
[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.
Requirements
Implementation: msxml4.dll, msxml2.lib
[C/C++]
Header and LIB files: msxml2.h, msxml2.lib
Version 4.0 Dependent ProgID: SAXXMLReader40
Version 4.0 Dependent CLSID: 88d969c7-f192-11d4-a65f-0040963251e5
To view reference information for Visual Basic or C/C++ only, click the Language Filter button
in the upper-left corner of the page.