# Remove Method

> Removes the XML element at an index from 1 to Count from an XMLElements collection; returns 0 on error, 1 if the DTD makes it invalid, 2 on success.

- **Product:** TX Text Control ActiveX
- **Section:** Documentation
- **Kind:** Method
- **Path:** TX Text Control ActiveX > API Reference > XMLElements > Remove Method
- **377 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelements/remove-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelements/remove-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelements/remove-method/llms-full.txt

---

Removes an XML element from an [XMLElements](https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelements/llms-full.txt) collection.

### Syntax

```vbscript
XMLElements.Remove Index
```

### Parameters

| Parameter | Description |
|---|---|
| Index | Specifies the position of the XML element in the collection. It must be a number from 1 to the value of the collection's [Count](https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelements/count-property/llms-full.txt) property. If this value does not match any existing member of the collection, an error occurs. |

### Return Value

| 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](https://docs.textcontrol.com/tx-text-control-activex/reference/txtextcontrol/xmlinvalid-event/llms-full.txt) event. |
| 2 | The element has been successfully removed. |

### Data Types

| Name | Data type |
|---|---|
| Index | Long |
| Return value | Integer |

### Examples

The following Basic example removes the second Address element of an XML document that contains addresses:

```vbscript
TXTextControl1.XMLElements("Address").Remove(2)
```

### See Also

- [Working with XML Files](https://docs.textcontrol.com/tx-text-control-activex/document-editor/xml/llms-full.txt)
- [XMLElement Object](https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelement/llms-full.txt)
- [XMLElements Collection](https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelements/llms-full.txt)
- [Programming Category: XML Programming](https://docs.textcontrol.com/tx-text-control-activex/reference/categories/xml/llms-full.txt)

---

## Nearby

- **Previous:** [Item Method](https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelements/item-method/llms-full.txt)
- **Next:** [Obsolete Properties, Methods and Events](https://docs.textcontrol.com/tx-text-control-activex/reference/obsolete-members/llms-full.txt)
