InsertElementNS method: XmlNode class

Syntax

InsertElementNS(NamespaceURI, TagName, Position)

where NamespaceURI can have one of the following forms:

URL.URLname 

OR a string URL, such as

http://www.example.com/

Description

Use InsertElementNS to insert a new element in an XmlNode, at the location specified by Position.

Parameters

Parameter Description

NamespaceURI

Specify the URI that contains the Namespaces for the XmlDoc.

TagName

Specify the name of the element that you want to create, as a string.

Position

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

Returns

A reference to the newly created element.

Example

For example:

Local XmlDoc &inXMLDoc;
Local XmlNode &dataNode;
Local XmlNode &elementNode;

&inXMLDoc = CreateXmlDoc("<?xml version='1.0'?><root xmlns='http:⇒
//www.example.com'/>");
&dataNode = &inXMLDoc.DocumentElement.AddElement("data");
&elementNode = &dataNode.AddElement("first");
&elementNode = &dataNode.AddElement("second");

&elementNode = &dataNode.InsertElementNS("http://www.example.com", "third", 2);

This is the XML document before the insert:

<?xml version="1.0"?>
<root xmlns="http://www.example.com">
  <data>
    <first/>
    <second/>
  </data>
</root>

This is the XML document after the insert:

<?xml version="1.0"?>
<root xmlns="http://www.example.com">
  <data>
    <first/>
    <third/>
    <second/>
  </data>
</root>