# XmlElement.RemoveChild Method

> Removes an XML child element.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Method
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > XmlElement.RemoveChild Method
- **895 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlelement/removechild-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlelement/removechild-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlelement/removechild-method/llms-full.txt

---

### Description

Removes an XML child element.

### Syntax

#### RemoveChild(string)

Removes the first XML child element with the specified name.

```csharp
public bool RemoveChild(string name);
```

```vbnet
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.

```csharp
public bool RemoveChild(string name, int index);
```

```vbnet
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:

```csharp
textControl1.GetXmlElements("Adress").GetItem(2).RemoveChild("Telephone", 2);
```

```vbnet
TextControl1.GetXmlElements("Adress").GetItem(2).RemoveChild("Telephone", 2)
```

The following example removes a child XML element.

```csharp
if (xmlElement.RemoveChild("CustomerName", 1))
{
    Console.WriteLine("Remove Child completed successfully.");
}
```

```vbnet
If xmlElement.RemoveChild("CustomerName", 1) Then
    Console.WriteLine("Remove Child completed successfully.")
End If
```

---

## Nearby

- **Previous:** [XmlElement.GetChildItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlelement/getchilditem-method/llms-full.txt)
- **Next:** [XmlElement.Select Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlelement/select-method/llms-full.txt)
