Xmlnode_Object RemoveElement Method

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

xmlnode_object.RemoveElement(element)

Prerequisites

The current node must be of type "element" or "document".

Parameters

element

A required string expression that specifies the name of the element to be removed.

Remarks

This is a convenience method that finds and removes a specified child element node in a DOM tree. The removed element node and the nodes beneath it are deleted and are no longer available. If the element is not found, an exception is thrown. The element must be an immediate child of the current node.

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.RemoveElement("section1") ' Removes "section1"

See Also

XML Classes | xmlnode_object.AddElement|xmlnode_object.RemoveAttribute| xmlnode_object.RemoveChild