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

# setChildren(_:)

Removes all existing children of the receiver and replaces them with an array of new child nodes.

```
func setChildren(_ children: [XMLNode]?)
```

## Parameters

`children`

An array of [`XMLNode`](/documentation/Foundation/XMLNode) objects. To remove all existing children, pass in `nil`.

## Discussion

Replaced or removed child nodes are released.

---

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)