---
title: "replaceChild(at:with:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/xmldtd/replacechild(at:with:)"
---

# replaceChild(at:with:)

Replaces a child at a particular index with another child.

## Declaration

```swift
func replaceChild(at index: Int, with node: XMLNode)
```

## Parameters

- `index`: An integer identifying the position of a node in the receiver’s list of child nodes.
- `node`: An doc://com.apple.foundation/documentation/Foundation/XMLNode object to replace the object at index.

## Discussion

Discussion The replaced child node is 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)
- [setChildren(_:)](foundation/xmldtd/setchildren(_:).md)
