InsertText method: XmlNode class

Syntax

InsertText(Data, Position)

Description

Use the InsertText method to insert a text node. The node is inserted at the location indicated by Position.

Note:

A text node is not the same as a text declaration. The text declaration is added automatically with the CreateXmlDoc function. A text node just contains text within an XmlDoc.

Parameters

Parameter Description

Data

Specify the data to be used for the text node, as a string.

Position

Specify where you want to insert the text node, as a number.

Returns

A reference to the newly created text node.

Example

For example:

Local XmlDoc &inXMLDoc;
Local XmlNode &textNode;

&inXMLDoc = CreateXmlDoc("<?xml version='1.0'?><root/>");
&textNode = &inXMLDoc.DocumentElement.AddText("first text");
&textNode = &inXMLDoc.DocumentElement.AddText("second text");

&textNode = &inXMLDoc.DocumentElement.InsertText("third text", 2);

This is the XML document before the insert:

<?xml version="1.0"?>
<root>
first textsecond text</root>

This is the XML document after the insert:

<?xml version="1.0"?>
<root>
first textthird textsecond text</root>