Partager via


MXHTMLWriter CoClass

 

The MXHTMLWriter CoClass generates HTML output from Simple API for XML (SAX) events and handles many of the details of outputting content in HTML format. When connected to SAXXMLReader, and set as a ContentHandler, MXHTMLWriter accumulates content passed by events thrown by the reader. This content is stored in the output buffer of MXHTMLWriter. The MXXMLWriter CoClass implements the IMXWriter interface.

Note

This feature is not available in MSXML 3.0. With MSXML 6.0, 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.

Results generated by MXHTMLWriter are exposed through the MXHTMLWriter.output property. MXHTMLWriter provides several properties that enable you to modify the results generated by it. For example, to enable "pretty printing," set the MXHTMLWriter.indent property to True.

To enable MXHTMLWriter to catch handler events passed by SAXXMLReader, you must set MXHTMLWriter as the ContentHandler, and optionally as any of the other handlers. The following table shows the handler interfaces implemented by MXHTMLWriter.

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

With MXHTMLWriter, HTML is output according to the HTML output method, as defined in the XSL Transformations (XSLT) Version 1.0 recommendation.

In general, MXHTMLWriter outputs HTML content like XML, with the following exceptions:

  • The following elements are recognized as empty elements. They are recognized in any combination of uppercase and lowercase. These elements are output with a start tag but no end tag.

    <area> <frame> <links>
    <base> <hr> <meta>
    <basefont> <img> <param>
    <br> <input>
    <col> <isindex>
  • The <script> and <style> elements do not require escaping of special characters. In the textual content of these elements, a "<" character will be output as "<", not as "<".

  • HTML attributes that have a URI value, such as the href attribute of the <a> element or the src attribute of the <image> element, are recognized. Special characters within a URI are escaped as specified in the HTML specification. For example, non-ASCII characters in the URI should be represented by converting each byte of the UTF-8 representation "%hh" where hh represents the byte value in hexadecimal. For example, spaces are represented as "%20".

  • MXHTMLWriter may output a character using a character entity reference if one is defined for it in the version of HTML that is specified.

  • Processing instructions are terminated with ">" rather than "?>".

  • Attributes that are written with a keyword only, and no value, will be recognized and output in this form. For example, in HTML, <OPTION SELECTED> shorthand is acceptable, but in XML it must be written as <OPTION SELECTED="SELECTED">. The HTML output method will normally use the abbreviated form, as this is the only form recognized by earlier HTML browsers.

  • The special use of the ampersand character in dynamic HTML attributes is recognized. For example, although the tag <TD HEIGHT=&{height};> is valid HTML, it would not be valid XML because of the ampersand character.

Properties

byteOrderMark Determines whether or not to write the Byte Order Mark (BOM).
disableOutputEscaping Determines whether disableOutputEscaping is on or off. When set to True, special symbols such as "&" are passed through literally.
encoding Sets encoding for the output.
indent Sets whether to indent output. Useful for "pretty printing."
omitXMLDeclaration Not supported by MXHTMLWriter.
output Sets the destination for the output generated by MXHTMLWriter.
standalone Not supported by MXHTMLWriter.
version Not supported by MXHTMLWriter.

Methods

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

Requirements

Implementation:

Msxml6.dll, msxml6.lib (MSXML 6.0)

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

Versioning

Implemented in: MSXML 6.0