From: sgunderson at bigfoot dot com Operating system: Debian PHP version: 5.3CVS-2009-02-28 (snap) PHP Bug Type: DOM XML related Bug description: No way of removing redundant xmlns: declarations
Description: ------------ There seems to be no good way of manipulating XML namespace declarations at all. In particular, they never get garbage collected in any way, and you cannot remove them manually, so they will stick around forever unless you create a new one. My typical use case is shown in the reproduce code below (although the element will typically have child elements). Since 5.3 (bug #38949) it seems I can getAttribute() the xmlns element, but still not remove it it any reasonable way (and it should really just disappear by itself; it does in other languages). Reproduce code: --------------- <?php $doc = new DOMDocument; $doc->loadXML('<html xmlns="something"><element xmlns:ns="whatever" ns:foo="bar" /></html>'); $root = $doc->documentElement; $elem = $root->firstChild; $elem->removeAttributeNode($elem->attributes->item(0)); print $doc->saveXML(); ?> Expected result: ---------------- <?xml version="1.0"?> <html xmlns="something"><element/></html> Actual result: -------------- <?xml version="1.0"?> <html xmlns="something"><element xmlns:ns="whatever"/></html> -- Edit bug report at http://bugs.php.net/?id=47531&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=47531&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=47531&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=47531&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=47531&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=47531&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=47531&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=47531&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=47531&r=needscript Try newer version: http://bugs.php.net/fix.php?id=47531&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=47531&r=support Expected behavior: http://bugs.php.net/fix.php?id=47531&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=47531&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=47531&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=47531&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47531&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=47531&r=dst IIS Stability: http://bugs.php.net/fix.php?id=47531&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=47531&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=47531&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=47531&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=47531&r=mysqlcfg