note 47905 added to function.domnode-remove-child
| From: | iloveitalyatgmail dot com at osu1 dot php dot net | Date: | Sun, 05 Dec 2004 02:28:56 +0000 |
| Subject: | note 47905 added to function.domnode-remove-child | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81372@lists.php.net to get a copy of this message | ||
The remove_child() function seems to have a bug. if the parent node of the node you are trying to
delete is the same as the root node it will give you unexpected errors. I fixed this by checking if
the parent node of the node i was deleting was the same as the document node. take a look at the
function below if you are running into the same problem. $this->xmlData reffers to the domxml
object inside the class i was using.
<?php
function deleteNode($ref, $levels) {
$parent = $ref->parent_node();
$root = $this->xmlData->document_element();
if($parent->node_name()==$root->node_name()) {
$parent = $this->xmlData->document_element();
}
if($parent->remove_child($ref)) {
return true;
} else {
exit("error removing node");
}
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.domnode-remove-child.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47905
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47905&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47905&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47905&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47905&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47905&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47905&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47905&report=yes
Search -- http://master.php.net/manage/user-notes.php