#42034 [NEW]: Attributes not deleted properly

From: Date: Wed, 18 Jul 2007 16:15:16 +0000
Subject: #42034 [NEW]: Attributes not deleted properly
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115202@lists.php.net to get a copy of this message
From: mail_ben_schmidt at yahoo dot com dot au Operating system: Mac OS X PHP version: 5CVS-2007-07-18 (snap) PHP Bug Type: SimpleXML related Bug description: Attributes not deleted properly Description: ------------ In SimpleXML, when deleting attributes via 'unset', attributes having the same namespace as the element (or some such wrong namespace) are deleted rather than the non-prefixed one which is the one actually appearing in the 'array' (or not appearing--it can still be deleted if it does not appear). Reproduce code: --------------- $str=<<<DONE <?xml version="1.0" encoding="utf-8"?> <root xmlns="http://localhost/a" xmlns:ns="http://localhost/a" xmlns:other="http://localhost/b" > <elem attr="abc"/> <elem ns:attr="abc"/> <elem other:attr="abc"/> <ns:elem attr="abc"/> <ns:elem ns:attr="abc"/> <ns:elem other:attr="abc"/> <other:elem attr="abc"/> <other:elem ns:attr="abc"/> <other:elem other:attr="abc"/> </root> DONE; $xml = simplexml_load_string($str); foreach ($xml->elem as $elem) { unset($elem['attr']); } foreach ($xml->children('http://localhost/a')->elem as $elem) { unset($elem['attr']); } foreach ($xml->children('http://localhost/b')->elem as $elem) { unset($elem['attr']); } echo $xml->asXML(); Expected result: ---------------- <?xml version="1.0" encoding="utf-8"?> <root xmlns="http://localhost/a" xmlns:ns="http://localhost/a" xmlns:other="http://localhost/b"> <elem/> <elem ns:attr="abc"/> <elem other:attr="abc"/> <ns:elem/> <ns:elem ns:attr="abc"/> <ns:elem other:attr="abc"/> <other:elem/> <other:elem ns:attr="abc"/> <other:elem other:attr="abc"/> </root> Actual result: -------------- <?xml version="1.0" encoding="utf-8"?> <root xmlns="http://localhost/a" xmlns:ns="http://localhost/a" xmlns:other="http://localhost/b"> <elem/> <elem/> <elem other:attr="abc"/> <ns:elem attr="abc"/> <ns:elem/> <ns:elem other:attr="abc"/> <other:elem attr="abc"/> <other:elem ns:attr="abc"/> <other:elem/> </root> -- Edit bug report at http://bugs.php.net/?id=42034&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42034&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42034&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42034&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42034&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42034&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42034&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42034&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42034&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42034&r=support Expected behavior: http://bugs.php.net/fix.php?id=42034&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42034&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42034&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42034&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42034&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42034&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42034&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42034&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42034&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42034&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42034&r=mysqlcfg

« previous php.bugs (#115202) next »