InsertCDataSection method: XmlNode class

Syntax

InsertCDataSection(Data, Position)

Description

Use the InsertCDataSection method to insert a CDATA section in an XmlNode, at the location specified by Position.

Note:

You cannot use this method with a SoapDoc object.

Parameters

Parameter Description

Data

Specify the data for the CDATA section as a string.

Position

Specify where you want to insert the CDATA Section, as a number.

Returns

A reference to the newly created CDATA section.

Example

For example:

Local XmlDoc &inXMLDoc;
Local XmlNode &dataNode;
Local XmlNode &cdataNode;

&inXMLDoc = CreateXmlDoc("<?xml version='1.0'?><root/>");
&dataNode = &inXMLDoc.DocumentElement.AddElement("data");
&cdataNode = &dataNode.AddCDataSection("this is a bunch of text");
&cdataNode = &dataNode.AddCDataSection("still more text");

&cdataNode = &dataNode.InsertCDataSection("more text", 2);

This is the XML document before the insert:

<?xml version="1.0"?>
<root>
  <data>
    <![CDATA[this is a bunch of text]]>
    <![CDATA[still more text]]>
  </data>
</root>

This is the XML document after the insert:

<?xml version="1.0"?>
<root>
  <data>
    <![CDATA[this is a bunch of text]]>
    <![CDATA[more text]]>
    <![CDATA[still more text]]>
  </data>
</root>