<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/XMLDocument/insertChildren(_:at:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSXMLDocument(im)insertChildren:atIndex:"
  },
  "title" : "insertChildren(_:at:)"
}
-->

# insertChildren(_:at:)

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

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

## Parameters

`children`

An array of [`XMLNode`](/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.

## Discussion

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)