System.Xml.XmlNode.ReplaceChild Method

Replaces the child node oldChild with newChild node.

Syntax

public virtual XmlNode ReplaceChild (XmlNode newChild, XmlNode oldChild)

Parameters

newChild
The new node to put in the child list.
oldChild
The node being replaced in the list.

Returns

The node replaced.

Remarks

If the newChild is already in the tree, it is first removed.

If the newChild 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 passed to the ReplaceChild method.

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