WriteCData

Writes out a CDATA section that contains the specified text.


HRESULT WriteCData (const WCHAR * pwszText);

pwszText

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

Returns S_OK if no error is generated.

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 Writing an XML Document Using XmlLite.

Header: XmlLite.h

Library: XmlLite.lib

Show:
© 2014 Microsoft