DOMDocument::replaceChildren
PHP function
Edit on GitHub ✎
(PHP 8 >= 8.3.0)
Replace children in document
Description
DOMDocument::replaceChildren(DOMNode|string ...$nodes): void
Replaces the children in the document with new nodes.
Examples
DOMDocument::replaceChildren example
Replaces the children with new nodes.
php
<?php
$doc = new DOMDocument;
$doc->loadXML("<container><hello/></container>");
$doc->replaceChildren("beautiful", $doc->createElement("world"));
echo $doc->saveXML();
?>The above example will output:
output
<?xml version="1.0"?>
beautiful
<world/>See Also
DOMParentNode::replaceChildrenDOMDocument::appendDOMDocument::prepend