# ChildItem Method

> Returns the child XMLElement with the given element name, with an optional Index for elements with several sub-elements of that name, and a Basic example.

- **Product:** TX Text Control ActiveX
- **Section:** Documentation
- **Kind:** Method
- **Path:** TX Text Control ActiveX > API Reference > XMLElement > ChildItem Method
- **329 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelement/childitem-method/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelement/childitem-method/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelement/childitem-method/llms-full.txt

---

Returns an [XMLElement](https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelement/llms-full.txt) object that is a child element of this element. If this element has more than one sub-elements of the type with the given name the optional Index parameter can be used to specify the subelement. If Index is omitted Text Control returns the first sub-element with the given name.

### Syntax

```vbscript
XMLElement.ChildItem ElementName[, Index]
```

### Parameters

| Parameter | Description |
|---|---|
| ElementName | Specifies the name of the sub-element. |
| Index | Optional. Specifies the number of the subelement. If this value does not match any existing sub-element, an error occurs. |

### Return Value

The method returns an [XMLElement](https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelement/llms-full.txt) object.

### Examples

The following Basic example gets the Telephone element from the second address in an XML document that contains addresses consisting of the sub-elements Name, Street, City and Telephone:

```vbscript
Dim Telephone As String
Set Addresses = TXTextControl1.XMLElements("Address")
Telephone = Addresses(2).ChildItem("Telephone")
```

### See Also

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

---

## Nearby

- **Previous:** [AutoText Property](https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelement/autotext-property/llms-full.txt)
- **Next:** [ElementName Property](https://docs.textcontrol.com/tx-text-control-activex/reference/xmlelement/elementname-property/llms-full.txt)
