disableOutputEscaping Property

MSXML 5.0 SDK

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

disableOutputEscaping Property

Specifies whether the disableOutputEscaping is on or off. When set to True, special symbols, such as "&", are passed through literally. When disableOutputEscaping is set to False, special symbols, (also known as built-in entities), such as "&", are escaped to &.

[Visual Basic]

Usage Syntax

oMXXMLWriter.disableOutputEscaping = boolValue
boolValue = oMXXMLWriter.disableOutputEscaping

Remarks

Boolean. Read/write. The default value is False. Normally, when you try to output a special character such as "<" or "&", the special character will be escaped in the output file using the standard XML escaping mechanism. For example, by default, MXHTMLWriter writes the "&" symbol as "&amp;". If disableOutputEscaping is set to True, the XML parser does not escape the special symbol and writes the "&" symbol as the literal "&".

Example

For elements such as <script> and <style>, MXHTMLWriter passes through special characters. For others, you may want to set disableOutputEscaping property to True, as shown in the following example.

Dim wrt As New MXHTMLWriter50
Dim cnth As IVBSAXContentHandler
Dim atrs As New SAXAttributes50
Set cnth = wrt

cnth.startDocument
cnth.startElement "", "", "html", atrs
cnth.startElement "", "", "script", atrs
cnth.characters "var a = 0;"
cnth.characters "var b = 1;"
cnth.characters "if (a < b) alert('hello')"
cnth.endElement "", "", "script"
cnth.startElement "", "", "body", atrs
wrt.disableOutputEscaping = True
cnth.characters "GG&G"  
wrt.disableOutputEscaping = False
cnth.endElement "","","body"
cnth.endElement "","","html"
MsgBox wrt.output

Example Output

The preceding example code passes through the "<" character as a literal within the <script> tags. However, to pass through the "&" character in the company name GG&G, you must set the disableOutputEscaping property to True. If disableOutputEscaping is set to False, the "&" character is escaped as &amp;.

<html><script>var a = 0;var b = 1;if (a < b) alert('hello')</script>
   <body>GG&G
   </body>
</html>
[C/C++]

Syntax

[propput]
HRESULT disableOutputEscaping (
   [in] VARIANT_BOOL fValue);
[propget]
HRESULT disableOutputEscaping (
   [out, retval] VARIANT_BOOL * fValue);

Parameters

fValue
A Boolean expression (True/False) specifying whether the feature is on or off.

Return Values

S_OK
The value returned if no errors are reported.

Remarks

If this property is set to True, the XML output may not be well-formed or valid.

Value Description
True MXXMLWriter does not escape special symbols (passing them through as literals) when writing output.
False (default) MXXMLWriter escapes special symbols when writing output.

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.

See Also

IMXWriter Interface | MXXMLWriter CoClass

Applies to: MXHTMLWriter CoClass