|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-28 23:39 UTC] rrichards@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 05:00:01 2025 UTC |
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"