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

# insertChild(_:at:)

Inserts a child node in the receiver’s list of children at a specific location in the list.

```
func insertChild(_ child: XMLNode, at index: Int)
```

## Parameters

`child`

An XML-node object that represents the child to insert.

`index`

An integer identifying the location in the receiver’s list of children to insert `child`. The indices of subsequent children in the list are incremented by one.

---

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)