MXXMLWriter CoClass

MSXML 5.0 SDK

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

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.

For MSXML 5.0, the version-dependent CoClass is MXMLWriter50, which uses the following programming class ID information:

(CLSID_MXXMLWriter50: 8d969c8-f192-11d4-a65f-0040963251e5)

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.

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

[Visual Basic]

Implementation: msxml5.dll, msxml2.lib

[C/C++]

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

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