System.Xml.XmlNode.InsertBefore Method

Inserts the specified node immediately before the specified reference node.

Syntax

public virtual XmlNode InsertBefore (XmlNode newChild, XmlNode refChild)

Parameters

newChild
The XmlNode to insert.
refChild
The XmlNode that is the reference node. The newChild is placed before this node.

Returns

The node being inserted.

Remarks

If refChild is null, insert newChild at the end of the list of child nodes. All the contents of the newChild are inserted, in the same order, before 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.

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