note 88592 modified in domnode.removechild by thiago
| From: | thiago@php.net | Date: | Fri, 30 Jan 2009 17:07:22 +0000 |
| Subject: | note 88592 modified in domnode.removechild by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-149986@lists.php.net to get a copy of this message | ||
These two functions might be helpful to anyone trying to delete a node and all of its children:
<?php
function deleteNode($node) {
deleteChildren($node);
$parent = $node->parentNode;
$oldnode = $parent->removeChild($node);
}
function deleteChildren($node) {
while (isset($node->firstChild)) {
deleteChildren($node->firstChild);
$node->removeChild($node->firstChild);
}
}
?>
--was--
These two functions might be helpful to anyone trying to delete a node and all of its children:
function deleteNode($node) {
deleteChildren($node);
$parent = $node->parentNode;
$oldnode = $parent->removeChild($node);
}
function deleteChildren($node) {
while (isset($node->firstChild)) {
deleteChildren($node->firstChild);
$node->removeChild($node->firstChild);
}
}
http://php.net/manual/en/domnode.removechild.php