XMLElement.RemoveChild Method

Removes a sub-element from this element. If this element has more than one sub-element of the type with the given name, the optional Index parameter can be used to specify the sub-element to remove. If Index is omitted Text Control removes the first sub-element with the given name.


   XMLElement.RemoveChild ElementName[, Index]
Parameter Description

Specifies the name of the sub-element to remove.


Optional. Specifies the number of the subelement. If this value does not match any existing sub-element, an error occurs.

Return Value

The method returns one of the following values:

Value Description
0 An error has occurred.
1 The element could not be removed because the document becomes invalid according to the document's DTD. In this case Text Control fires an XMLInvalid event.
2 The sub-element has successfully been removed.


The following Basic example removes the second "Telephone" element of the second address in an XML document that contains addresses consisting of the sub-elements Name, Street, City and Telephone:

TXTextControl1.XMLElements("Address")(2).RemoveChild "Telephone", 2

See Also