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-domno
de-removechild.php
Edit -- https://master
.php.net/note/edit/78326
Del: integrated -- h
ttps://master.php.net/note/delete/78326/integrated
Del: useless -- http
s://master.php.net/note/delete/78326/useless
Del: bad code -- htt
ps://master.php.net/note/delete/78326/bad+code
Del: spam -- https:/
/master.php.net/note/delete/78326/spam
Del: non-english --
https://master.php.net/note/delete/78326/non-english
Del: in docs -- http
s://master.php.net/note/delete/78326/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/78326
Reject -- https://mast
er.php.net/note/reject/78326
Search -- https://
master.php.net/manage/user-notes.php
--
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php
|