#38474 [Asn->Csd]: getAttribute select attribute by order, even when prefixed
| From: | rrichards@php.net | Date: | Mon, 28 Aug 2006 23:39:10 +0000 |
| Subject: | #38474 [Asn->Csd]: getAttribute select attribute by order, even when prefixed | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101462@lists.php.net to get a copy of this message | ||
ID: 38474
Updated by: rrichards@php.net
Reported By: thedeathart at gmail dot com
-Status: Assigned
+Status: Closed
Bug Type: DOM XML related
Operating System: Windows XP
PHP Version: 5.1.4
Assigned To: rrichards
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2006-08-16 17:27:35] thedeathart at gmail dot com
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 this bug report at http://bugs.php.net/?id=38474&edit=1