22 $newnode = $node->ownerDocument->createElement(
$name);
24 foreach ($node->childNodes as $child) {
25 $child2 = $child->cloneNode(
true);
26 $newnode->appendChild($child2);
28 if ($keep_attributes) {
29 foreach ($node->attributes as $attrName => $attrNode) {
30 $newnode->setAttribute($attrName, $attrNode);
33 $node->parentNode->replaceChild($newnode, $node);
46 $newnode = $node->ownerDocument->createElement(
$name);
49 $par = $node->parentNode;
52 if ($next_sib = $node->nextSibling) {
53 $newnode = $par->insertBefore($newnode, $next_sib);
55 $newnode = $par->appendChild($newnode);
58 $node = $par->removeChild($node);
59 $newnode->appendChild($node);
78 foreach ($node->childNodes as $child) {
79 $child2 = $child->cloneNode(
true);
80 $node->parentNode->insertBefore($child2, $node);
82 $node->parentNode->removeChild($node);
static replaceByChilds($node)
Replace a node by its child.
static changeName($node, $name, $keep_attributes=true)
Change name of a node.
static addParent($node, $name)
Add parent.