# XmlElementCollection Class

> An instance of this class contains all elements of an XML document that have the same element name. It can be obtained with the TextControl.GetXmlElements method.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Class
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WinForms.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Implements:** `System.Collections.ICollection`, `System.Collections.IEnumerable`
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > XmlElementCollection Class
- **663 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/llms-full.txt

---

### Description

An instance of this class contains all elements of an XML document that have the same element name. It can be obtained with the [TextControl.GetXmlElements](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/getxmlelements-method/llms-full.txt) method.

### Syntax

```csharp
public class XmlElementCollection : ICollection, IEnumerable
```

```vbnet
Public Class XmlElementCollection
    Implements ICollection, IEnumerable
```

### Examples

The following example includes the count value from a Xml Element Collection object in application diagnostics. The created object is then available to the surrounding document workflow.

```csharp
Console.WriteLine($"Count: {xmlElementCollection.Count}");
Console.WriteLine("Xml Element Collection is ready for use.");
```

```vbnet
Console.WriteLine($"Count: {xmlElementCollection.Count}")
Console.WriteLine("Xml Element Collection is ready for use.")
```

---

## In This Section

- [XmlElementCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/add-method/llms-full.txt): Adds the specified XML element to the collection.
- [XmlElementCollection.CopyTo Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/copyto-method/llms-full.txt): Copies the elements of the collection to an array, starting at a particular index.
- [XmlElementCollection.Count Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/count-property/llms-full.txt): Gets the number of XML elements in the collection.
- [XmlElementCollection.GetEnumerator Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/getenumerator-method/llms-full.txt): Returns an enumerator that can be used to iterate through the collection.
- [XmlElementCollection.GetItem Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/getitem-method/llms-full.txt): Returns a particular XML element from the collection.
- [XmlElementCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/remove-method/llms-full.txt): Removes an XML element from an XML document.

---

## Nearby

- **Previous:** [XmlElement.Text Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelement/text-property/llms-full.txt)
- **Next:** [XmlElementCollection.Add Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/xmlelementcollection/add-method/llms-full.txt)
