Partager via


WriteCData (Compact 7)

3/12/2014

This method 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 equal to an empty string.

Return Value

This method 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, as shown in the following example:

<![CDATA[]]>

If the text block provided contains the characters "]]>", which indicate 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 shows using WriteCData:

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

See Also

Reference

IXmlWriter Methods
IXmlWriter Properties