ID: 48916 User updated by: piotr dot baranowski at zeno dot pl -Summary: Add feature to delete XML node in SimpleXML Reported By: piotr dot baranowski at zeno dot pl Status: Bogus Bug Type: Feature/Change Request Operating System: All of them PHP Version: 5.2.10 New Comment:
Sorry, i forgot to write that this is about nodes selected by xpath ;-) Yeah, i know, so lame of me. <?php $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?> <root> <recipes> <recipe> <id>1</id> </recipe> <recipe> <id>2</id> </recipe> </recipes> </root>'); print_r($xml); $node = $xml->xpath('recipes/recipe[id="1"]'); $foo = &$node[0]; unset($node[0]); $node[0] = null; unset($foo); $foo = null; print_r($xml); ?> print_r gives same result before and after unset or setting node to null. It's because only the reference, not content of reference, is unset(). There's no way to delete (or no way that i could thought about) to delete node selected by xpath. Previous Comments: ------------------------------------------------------------------------ [2009-07-14 15:09:05] rricha...@php.net no need for additional method. unset() performs deletions ------------------------------------------------------------------------ [2009-07-14 14:53:03] piotr dot baranowski at zeno dot pl Description: ------------ Just as in the title. There's no way now to delete XML node in SimpleXML. It would be nice to have SimpleXML method that would delete given node. Reproduce code: --------------- --- >From manual page: book.simplexml --- ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48916&edit=1