Skip to content

CData

Writes the specified value to the current element as CDATA.

1
myXmlWriter.CData(value: string):XmlWriter

Writes the specified value to a new element with the specified name as CDATA.

1
myXmlWriter.CData(elementName: string, value: string):XmlWriter

Parameters

string value
    Value to write as CDATA.

string elementName
    Name of the element to create.

Returns

The current XmlWriter instance, allowing for method chaining. The current XmlWriter instance, allowing for method chaining.

Remarks

This method writes the specified value to the current element, enclosed within a CDATA section. CDATA sections are used to escape blocks of text containing characters that would otherwise be interpreted as markup.

Example

1
2
3
4
5
6
var writer = $Xml.Create();
writer.StartElement('Customer');
writer.CData('Doe');
writer.EndElement();
var xml = writer.ToXml();
// xml: <Customer><![CDATA[Doe]]></Customer>

This method creates a new element with the specified name and writes the specified value as CDATA within that element.

Example

1
2
3
4
var writer = $Xml.Create();
writer.CData('Customer', 'Doe');
var xml = writer.ToXml();
// xml: <Customer><![CDATA[Doe]]></Customer>

See Also