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.
For MSXML 5.0, the version-dependent CoClass is MXHTMLWriter50
, which uses the following programming class ID information:
(CLSID_MXHTMLWriter: 88d969c9-f192-11d4-a65f-0040963251e5)
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 thesrc
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: msxml5.dll, msxml2.lib
Header and LIB files: msxml2.h, msxml2.lib
To view reference material for Visual Basic or C++ only, click the Language Filter button in the upper-left corner of the page.
Other Resources
W3C XSL Transformations (XSLT) Version 1.0 Recommendation