System.Xml.XmlNode.InsertAfter Method

Inserts the specified node immediately after the specified reference node.

Syntax

public virtual XmlNode InsertAfter (XmlNode newChild, XmlNode refChild)

Parameters

newChild
The XmlNode to insert.
refChild
The XmlNode that is the reference node. The newNode is placed after the refNode.

Returns

The node being inserted.

Remarks

If refChild is null, insert newChild at the beginning of the list of child nodes. All the contents of the newChild are inserted, in the same order, after refChild. If the newChild is already in the tree, it is removed from its original position and added to its target position. For more information about inserting nodes, see Inserting Nodes into an XML Document.

If the node being inserted was created from another document, you can use XmlDocument.ImportNode(XmlNode, bool) to import the node to the current document. The imported node can then be inserted into the current document.

This method is a Microsoft extension to the Document Object Model (DOM).

Requirements

Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0