WriteCData (IXmlWriterLite)

 

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:

<![CDATA[]]>

If the text block provided contains the characters "]]>", which signify 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 example 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 a complete code example that uses WriteCData, see Universal Windows Platform (UWP) XmlLite sample.

Requirements

Header: XmlLite.h

Library: XmlLite.lib

See Also

IXmlWriterLite Methods