#38474 [NEW]: getAttribute select attribute by order, even when prefixed

From: Date: Wed, 16 Aug 2006 17:27:35 +0000
Subject: #38474 [NEW]: getAttribute select attribute by order, even when prefixed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-100871@lists.php.net to get a copy of this message
From: thedeathart at gmail dot com Operating system: Windows XP PHP version: 5.1.4 PHP Bug Type: DOM XML related Bug description: getAttribute select attribute by order, even when prefixed Description: ------------ When using DomNode->getAttribute('attribute') the attribute is selected by the order in the xml, even if the attributes are prefixed with a namespace. So in the case of having several attributes with the same name, but one without namespace, and one/several with a namespace, getAttribute does not return the attribute without a namespace as expected, instead it selects the attributes by order, and returns the first one. The solution so this is using DomNode->getAttributeNS(null,'attribute') , but this being a complete hack. This seems as a unnessary bug, and compared to other DOM implements like python, it seems more normal to return the attribute without a namespace when using getAttribute, rather than the first one. Reproduce code: --------------- <?php $xml = '<node xmlns:pre="http://foo.com/tr/pre" pre:type="bar" type="foo" ><sub /></node>'; $dom = new DomDocument(); $dom->loadXML($xml); echo $dom->firstChild->getAttribute('type'); ?> Expected result: ---------------- the output should be "foo" Actual result: -------------- the output is "bar" -- Edit bug report at http://bugs.php.net/?id=38474&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=38474&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=38474&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=38474&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=38474&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=38474&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=38474&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=38474&r=needscript Try newer version: http://bugs.php.net/fix.php?id=38474&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=38474&r=support Expected behavior: http://bugs.php.net/fix.php?id=38474&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=38474&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=38474&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=38474&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=38474&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=38474&r=dst IIS Stability: http://bugs.php.net/fix.php?id=38474&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=38474&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=38474&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=38474&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=38474&r=mysqlcfg

« previous php.bugs (#100871) next »