共用方式為


WriteCData

 

Writes out a CDATA section that contains the specified text.

Syntax

  
HRESULT WriteCData (const WCHAR * pwszText);  

Arguments

pwszText
The content of the CDATA section. NULL is equivalent to an empty string.

Return Value

Returns S_OK if no error is generated.

Remarks

This method produces a CDATA section in the following format, where text is the provided text:

<![CDATA[text]]>  

When the pwszText parameter is NULL, this method produces a CDATA section that contains no content, like this:

<![CDATA[]]>  

If the text block provided contains the characters "]]>", which denote the end of a CDATA section, the writer creates a second CDATA section that contains the content after the second "]" character. This prevents the CDATA section from being truncated.

This method does not combine adjacent CDATA sections, even if there have been no other method calls between calls to the WriteCData method.

The following code illustrates the use of WriteCData:

if (FAILED(hr = pWriter->WriteCData(L"This is CDATA text.")))  
{  
    wprintf(L"Error, Method: WriteCData, error is %08.8lx", hr);  
    return -1;  
}  

For more detailed example of WriteCData, see Write an XML Document using XmlLite.

Requirements

Header: XmlLite.h

Library: XmlLite.lib

See Also

IXmlWriter Methods