---
title: "setChildren(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/xmldtd/setchildren(_:)"
---

# setChildren(_:)

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

## Declaration

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

## Parameters

- `children`: An array of doc://com.apple.foundation/documentation/Foundation/XMLNode objects. To remove all existing children, pass in nil.

## Discussion

Discussion Replaced or removed child nodes are released.

## See Also

### Manipulating Child Nodes

- [addChild(_:)](foundation/xmldtd/addchild(_:).md)
- [insertChild(_:at:)](foundation/xmldtd/insertchild(_:at:).md)
- [insertChildren(_:at:)](foundation/xmldtd/insertchildren(_:at:).md)
- [removeChild(at:)](foundation/xmldtd/removechild(at:).md)
- [replaceChild(at:with:)](foundation/xmldtd/replacechild(at:with:).md)
