# XmlElementCollection.Remove Method

> Removes an XML element from an XML document.

- **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 > XmlElementCollection.Remove Method
- **431 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlelementcollection/remove-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlelementcollection/remove-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlelementcollection/remove-method/llms-full.txt

---

### Description

Removes an XML element from an XML document.

### Syntax

```csharp
public bool Remove(int index);
```

```vbnet
Public Function Remove(index As Integer) As Boolean
```

### Parameters

| Parameter | Description |
|---|---|
| index | Specifies the one-based index of the XML element in the collection. If this parameter is zero, the element at the current input position is removed. |

### 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 element could successfully be removed.

### Examples

The following example removes an item from the xml element collection.

```csharp
if (xmlElementCollection.Remove(1))
{
    Console.WriteLine("Remove completed successfully.");
}
```

```vbnet
If xmlElementCollection.Remove(1) Then
    Console.WriteLine("Remove completed successfully.")
End If
```

---

## Nearby

- **Previous:** [XmlElementCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlelementcollection/getitem-method/llms-full.txt)
- **Next:** [XmlErrorEventArgs Class](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/xmlerroreventargs/llms-full.txt)
