Xmlnode_Object RemoveChild Method

Remove a specified child node and its subtree from the DOM tree.

xmlnode_object.RemoveChild(old_child)

Prerequisites

None

Parameters

old_child

A required XmlNode object that indicates the DOM tree node to remove.

Remarks

The DOM node (and its subtree) associated with the old_child object is removed from the tree. This node and its subtree can then be placed in the same tree at a different location.

The old_child object must be an immediate child of the current node.

If a node is removed from the DOM tree and not placed somewhere else in the same tree, it and its subtree are lost once the corresponding XmlNode object is destroyed.

Examples

Dim doc As XmlDoc 
Dim root As XmlNode
Dim elem1 As XmlNode
Dim
elem2 As XmlNode
doc = New XmlDoc("my_doc")
root = doc.DocumentElement
elem1 = root.AddElementNode("section1", "Data for section 1")
elem2 = root.AddElementNode("section2", "Data for section 2")
root.RemoveChild(elem1) ' "section1" is removed from the tree

See Also

XML Classes | xmlnode_object.RemoveAttribute| xmlnode_object.RemoveElement