(PHP 8 >= 8.3.0)
DOMDocumentFragment::replaceChildren — Replace children in fragment
   Replaces the children in the document fragment with new nodes.
  
nodesThe nodes replacing the children. Strings are automatically converted to text nodes.
Не повертає значень.
DOM_HIERARCHY_REQUEST_ERR
    Виникає, якщо тип цього вузла не дозволяє тип дочірнього вузла,
    котрий передано в параметр nodes, або якщо вузол,
    який потрібно додати, є одним із предків цього вузла або ним самим.
  
DOM_WRONG_DOCUMENT_ERR
    Виникає, якщо один з переданих nodes було створено не
    в тому документі, що і цей вузол.
   
| Версія | Опис | 
|---|---|
| 8.3.0 | Calling this method on a node without an owner document now works.
       Раніше викидалося виключення DOMException з кодом DOM_HIERARCHY_REQUEST_ERR. | 
Приклад #1 DOMDocumentFragment::replaceChildren() example
Replaces the children with new nodes.
<?php
$doc = new DOMDocument;
$doc->loadXML("<container><hello/></container>");
$fragment = $doc->createDocumentFragment();
$fragment->append("hello");
$fragment->replaceChildren("beautiful", $doc->createElement("world"));
echo $doc->saveXML($fragment);
?>Поданий вище приклад виведе:
beautiful <world/>
