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

# addChild(_:)

Adds a child node at the end of the receiver’s current list of children.

```
func addChild(_ child: XMLNode)
```

## Parameters

`child`

An XML node object to add to the receiver’s children.

## Discussion

The new node has an index value that is one greater than the last of the current children.

---

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)