IMXWriter Interface


The IMXWriter interface is a complementary application programming interface (API) to the latest version of the Simple API for XML (SAX2) implementation of Microsoft® XML Core Services (MSXML). MSXML provides two CoClasses that implement IMXWriter.

MXXMLWriterGenerates XML or DOM output.
MXHTMLWriterGenerates HTML output.

The following can be set as output for IMXWriter:

  • 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.

IMXWriter also enables you to:

  • control the output of a document by setting properties, such as omitXMLDeclaration, indent, and encoding.

  • generate XML or HTML content by invoking methods of the ISAXContentHandler, ISAXDTDHandler, ISAXDeclHandler, and ISAXLexicalHandler interfaces.

    System_CAPS_ICON_important.jpg Important

    The IMXWriter interface implements the ISAXContentHandler, ISAXDTDHandler, ISAXErrorHandler, ISAXDeclHandler, and ISAXLexicalHandler interfaces. However, to enable the writer to catch handler events passed by SAXXMLReader, you must set the writeras the ContentHandler, and, optionally, as any of the other handlers. For more information about how to set a writer as a handler, see Use MXXMLWriter.

Ideally, a writerconnected to SAXXMLReader produces the same document as provided on the input. However, the writer may miss content deemed ignorable by XML 1.0 specifications or may output in a different encoding. For example, national encoding can be replaced with Unicode Transformation Format (UTF-8 or UTF-16). Replacing the encoding becomes useful if you use a custom SAXXMLFilter between SAXXMLReader and the writer.

IMXWriter uses the generous input approach, which means it outputs what is entered. It is the responsibility of the application to ensure that SAX events and parameters match those of a well-formed or valid XML document.

byteOrderMarkDetermines whether to write the Byte Order Mark (BOM). The byteOrderMark property has no effect for BSTR or DOM output.
disableOutputEscapingMatches the disable-output-escaping attribute of the <xsl:text> and <xsl:value-of> elements. When set to True, special symbols such as "&" are passed through literally.
encodingSets and gets encoding for the output.
indentSets whether to indent output.
omitXMLDeclarationForces the IMXWriter to skip the XML declaration. Useful for creating document fragments.
outputSets the destination and the type of output for IMXWriter.
standaloneSets the value of the standalone attribute in the XML declaration to "yes" or "no".
versionSpecifies the version to include in XML declarations.

In addition to the preceding properties, the following method also applies to the IMXWriter interface.

flushFlushes the object's internal buffer to its destination IStream/string. The flush method has no effect for DOM output.


msxml3.dll, msxml2.lib (MSXML 3.0)

msxml6.dll, msxml6.lib (MSXML 6.0)

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

Implemented in: MSXML 3.0 and later