MXXMLWriter CoClass

 

MXXMLWriter generates XML output that can be:

  • Any implementation of the IStream interface. (The resulting document will be written into the provided IStream.)

  • A string.

  • A DOMDocument object. For more information about setting the output property to a DOMDocument object, see Create a DOMDocument Object from SAX Events

    When connected to SAXXMLReader, and set as a ContentHandler, MXXMLWriter accumulates XML content passed by events thrown by the reader. This content is stored in the MXXMLWriter's output buffer. The MXXMLWriter CoClass implements the IMXWriter interface.

With MSXML 3.0 and later, version-dependent CoClasses are provided that implement this interface. For more information on each version-specific CoClass, refer to the version-specific GUID and Prog ID reference topics in the GUIDs and ProgID Information section.

In addition to generating XML, MXXMLWriter also handles the details of collecting data produced by SAX events. For example, rather than concatenating strings within each method call of the ContentHandler, and dealing with issues such as the manual insertion of opening and closing brackets for startElement and EndElement events respectively, you can set MXXMLWriter to the IVBSAXContentHandler\ISAXContentHandler interface, and then make method calls on the ContentHandler to push data to MXXMLWriter. MXXMLWriter then writes opening brackets for the startElement event and closing brackets for the endElement event.

Results generated by MXXMLWriter are exposed through the MXXMLWriter.output property. MXXMLWriter provides several properties that enable you to modify output collected by MXXMLWriter. For example, to create an XML document fragment, set the MXXMLWriter.omitXMLDeclaration to True. In a similar way, you can set the MXXMLWriter.indent to True to enable "pretty printing."

To enable MXXMLWriter to catch handler events passed by SAXXMLReader, you set MXXMLWriter as the ContentHandler, and optionally as any of the other handlers. For more information about how to register MXXMLWriter as a handler, see Use MXXMLWriter.

The following table shows the handler interfaces implemented by MXXMLWriter.

Visual Basic Interfaces C++ Interfaces
IVBSAXContentHandler ISAXContentHandler
IVBSAXDeclHandler ISAXDeclHandler
IVBSAXDTDHandler ISAXDTDHandler
IVBSAXErrorHandler ISAXErrorHandler
IVBSAXLexicalHandler ISAXLexicalHandler

Properties

byteOrderMark Determines whether to write the Byte Order Mark (BOM).
disableOutputEscaping Turns disableOutputEscaping on or off. When disableOutputEscaping is set to True, special symbols such as "&" are passed through literally.
encoding Sets and gets encoding for the output.
indent Sets whether to indent output. Useful for "pretty printing."
omitXMLDeclaration Forces the MXXMLWriter to omit the XML declaration. Useful for creating document fragments.
output Determines the destination and the type of output for MXXMLWriter. Output can be stream, string, or DOM.
standalone Sets the value of the standalone attribute in the XML declaration to "yes" or "no".
version Specifies the version to include in XML declaration.

Methods

flush Flushes the object's internal buffer to its destination IStream/string.

Requirements

Implementation

msxml3.dll, msxml2.lib (MSXML 3.0)

msxml4.dll, msxml2.lib (MSXML 4.0)

msxml5.dll, msxml2.lib (MSXML 5.0 for Microsoft Office Applications)

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

Versioning

Implemented in: MSXML 3.0 and later