RemoveChild Method
- Namespace
TXTextControl
- Package
TXTextControl.asTextControl. WPF. SDK TXTextControl.from the private NuGet feed or Text Control Offline Packagesdll
Description
Removes an XML child element.
Syntax
RemoveChild(string)
Removes the first XML child element with the specified name.
public bool RemoveChild(string name);Public Function RemoveChild(name As String) As Boolean| Parameter | Description |
|---|---|
| name | Specifies the name of the sub-element to remove. |
RemoveChild(string, int)
Removes the XML child element with the specified name and index.
public bool RemoveChild(string name, int index);Public Function RemoveChild(name As String, index As Integer) As Boolean| Parameter | Description |
|---|---|
| name | Specifies the name of the sub-element to remove. |
| index | Specifies the number of the sub-element beginning with 1. If this value does not match any existing sub-element, an error occurs. |
Return Value
The return value is false, if the element could not be removed because the document becomes invalid according to the document's DTD. In this case, an XmlInvalid event occurs. The return value is true, if the sub-element could successfully be removed.
Examples
The following example removes the second Telephone element of the second address in an XML document that contains adresses consisting of the sub-elements Name, Street, City and Telephone:
textControl1.GetXmlElements("Adress").GetItem(2).RemoveChild("Telephone", 2);TextControl1.GetXmlElements("Adress").GetItem(2).RemoveChild("Telephone", 2)The following example removes a child XML element.
if (xmlElement.RemoveChild("CustomerName", 1))
{
Console.WriteLine("Remove Child completed successfully.");
}If xmlElement.RemoveChild("CustomerName", 1) Then
Console.WriteLine("Remove Child completed successfully.")
End If