InsertEntityReference method: XmlNode class

Syntax

InsertEntityReference(Name, Position)

Description

Use the InsertEntityReference method to add an entity reference. An entity reference refers to the content of the named entity.

Parameters

Parameter Description

Name

Specify the name of the entity to which this reference refers to.

Position

Specify where you want to insert the entity reference, as a number.

Returns

A reference to the newly created entity reference.

Example

For example:

Local XmlDoc &inXMLDoc;
Local XmlNode &dataNode;
Local XmlNode &entityRef;

&inXMLDoc = CreateXmlDoc("<?xml version='1.0'?><root/>");
&dataNode = &inXMLDoc.DocumentElement.AddElement("data");
&entityRef = &dataNode.AddEntityReference("first");
&entityRef = &dataNode.AddEntityReference("second");

&entityRef = &dataNode.InsertEntityReference("third", 2);

This is the XML document before the insert:

<?xml version="1.0"?>
<root>
  <data>
&first;&second;  </data>
</root>

This is the XML document after the insert:

<?xml version="1.0"?>
<root>
  <data>
&first;&third;&second;  </data>
</root>