---
title: "insertChildren(_:at:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/xmldocument/insertchildren(_:at:)"
---

# insertChildren(_:at:)

Inserts an array of children at a specified position in the receiver’s array of children.

## Declaration

```swift
func insertChildren(_ children: [XMLNode], at index: Int)
```

## Parameters

- `children`: An array of doc://com.apple.foundation/documentation/Foundation/XMLNode objects representing comments, processing instructions, or the root element.
- `index`: An integer identifying the location in the receiver’s children array for insertion. The indexes of children after the new child are increased by [children count]. If index is less than zero or greater than the number of children, an out-of-bounds exception is raised.

## See Also

### Adding and Removing Child Nodes

- [addChild(_:)](foundation/xmldocument/addchild(_:).md)
- [insertChild(_:at:)](foundation/xmldocument/insertchild(_:at:).md)
- [removeChild(at:)](foundation/xmldocument/removechild(at:).md)
- [replaceChild(at:with:)](foundation/xmldocument/replacechild(at:with:).md)
- [setChildren(_:)](foundation/xmldocument/setchildren(_:).md)
