note 78325 added to function.dom-domnode-removechild
| From: | VasilRangelov at osu1 dot php dot net | Date: | Sat, 06 Oct 2007 16:18:28 +0000 |
| Subject: | note 78325 added to function.dom-domnode-removechild | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131185@lists.php.net to get a copy of this message | ||
At the time of writing, I suppose rightfully, removeChild() removes only the selected node, but when
you remove an element, it's child elements are not removed. If you want to achieve that,
replaceChild() is the solution.
The following should remove all descendants of the $node DOMNode, regardless of it's name:
<?php
$node->replaceChild(new DOMElement($node->nodeName), $node);
?>
If you're replacing the root element, you must explicitly state that with
$node->documentElement as the second argument.
----
Server IP: 195.149.248.161
Probable Submitter: 83.148.87.92
----
Manual Page -- http://www.php.net/manual/en/function.dom-domnode-removechild.php
Edit -- https://master.php.net/note/edit/78325
Del: integrated -- https://master.php.net/note/delete/78325/integrated
Del: useless -- https://master.php.net/note/delete/78325/useless
Del: bad code -- https://master.php.net/note/delete/78325/bad+code
Del: spam -- https://master.php.net/note/delete/78325/spam
Del: non-english -- https://master.php.net/note/delete/78325/non-english
Del: in docs -- https://master.php.net/note/delete/78325/in+docs
Del: other reasons-- https://master.php.net/note/delete/78325
Reject -- https://master.php.net/note/reject/78325
Search -- https://master.php.net/manage/user-notes.php