disableOutputEscaping Property

MSXML 5.0 SDK

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

disableOutputEscaping Property

Matches the disable-output-escaping attribute of the <xsl:text> and <xsl:value-of> elements. For example, normally escaped built-in entities such as "&amp;" for "&" are passed through literally.

[Visual Basic]

Implementation Syntax

Property Let IMXWriter_disableOutputEscaping(ByVal RHS As Boolean)
Property Get IMXWriter_disableOutputEscaping() As Boolean

Usage Syntax

oMXXMLWriter.disableOutputEscaping = boolValue
boolValue = oMXXMLWriter.disableOutputEscaping

Remarks

Boolean. Read/write. The disableOutputEscaping property has no effect for DOM output.

Example

In some cases, you may want to merge an XML document fragment with an XML document. If the document fragment has not been parsed, the "&" character will be escaped as "&amp;" in the document fragment. However, if you merge the document fragment into an XML document, the "&amp;" will be escaped again when it is parsed. To avoid the situation where an already escaped character is escaped again, you can set the disableOutputEscaping property to True. The following code sample manually generates an XML document to demonstrate how this works. For the first element created, disableOutputEscaping is left as False, resulting in a double-escaped character. However, in the second element generated, disableOutputEscaping is set to True, enabling the "GG&amp;G" value to be passed through as intended.

Visual Basic File (Form1.frm)

Private Sub Command1_Click()

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

   'Starts the document by addding the XML declaration.
   cnth.startDocument

   'This section escapes the character.
   cnth.startElement "", "", "company", atrs
   cnth.characters "GG&amp;G"
   cnth.endElement "", "", "company"

   'This section passes the escaped character through as a literal.
   wrt.disableOutputEscaping = True
   cnth.startElement "", "", "company", atrs
   cnth.characters "GG&amp;G"
   cnth.endElement "", "", "company"

   'Ends the document.
   cnth.endDocument

   MsgBox wrt.output

End Sub

Try It!

  1. Open Visual Basic and create a new Standard EXE project.
  2. Create a reference in the project to Microsoft XML, v5.0.
  3. Add a command button (Command1) to the application form (Form1).
  4. From the View menu, click Code.
  5. Use copy and paste to replace any code in the form with the code provided above.
  6. From the Run menu, click Start.
  7. In the test application, click Command1 (the command button).

Output

The output in the message box is as follows:

<?xml version="1.0" encoding="UTF-16" standalone="no"?>
<company>GG&amp;amp;G</company>
<company>GG&amp;G</company>

Note that the "&" character has been escaped twice in the first <company> element ("GG&amp;amp;G") and passed through as intended (shown in bold) in the second <company> element.

[C/C++]

Syntax

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

Parameters

fValue
Boolean.

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. The disableOutputEscaping property has no effect for DOM output.

The XSLProcessor object does not implement the disableOutputEscaping property.

Value Description
True Writer cannot escape input when writing output.
False (default) Writer should escape input when writing output.

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

See Also

MXHTMLWriter CoClass | MXXMLWriter CoClass

Applies to: IMXWriter Interface