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

# setChildren(_:)

Sets the child nodes of the receiver.

## Declaration

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

## Parameters

- `children`: An array of doc://com.apple.foundation/documentation/Foundation/XMLNode objects. Each of these objects must represent comments, processing instructions, or the root element; otherwise, an exception is raised. Pass in nil to remove all children.

## See Also

### Adding and Removing Child Nodes

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