30 bool $keep_attributes =
true 32 $newnode = $node->ownerDocument->createElement($name);
34 foreach ($node->childNodes as $child) {
35 $child2 = $child->cloneNode(
true);
36 $newnode->appendChild($child2);
38 if ($keep_attributes) {
39 foreach ($node->attributes as $attrName => $attrNode) {
40 $newnode->setAttribute($attrName, $attrNode);
43 $node->parentNode->replaceChild($newnode, $node);
53 $newnode = $node->ownerDocument->createElement($name);
54 $par = $node->parentNode;
55 if ($next_sib = $node->nextSibling) {
56 $newnode = $par->insertBefore($newnode, $next_sib);
58 $newnode = $par->appendChild($newnode);
61 $node = $par->removeChild($node);
62 $newnode->appendChild($node);
69 foreach ($node->childNodes as $child) {
70 $child2 = $child->cloneNode(
true);
71 $node->parentNode->insertBefore($child2, $node);
73 $node->parentNode->removeChild($node);
static replaceByChilds(DOMNode $node)
static changeName(DOMNode $node, string $name, bool $keep_attributes=true)
static addParent(DOMNode $node, string $name)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...