# dom strange behaviours

- Thread: https://externals.io/message/29434
- Original archive: https://news-web.php.net/php.internals/29434
- Started by kepbepos kepbepos on 2007-05-15T10:21:49+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #29434 — kepbepos kepbepos — 2007-05-15T10:21:49+00:00

URL: https://externals.io/message/29434#29434

Hi all,

I've some problems with getAttribute* methods. I thing it is a bug, but
before  send it, I'd like to propose a little test to you all, just to have
a confirmation (maybe is my installation only).

first the code and after the output I got on three different  servers

-----------------------------------------------------------------------------------------------------------------------------------------

<?php

    $doc = '<root><node xml:id="one" at="one">first node</node><node
xml:id="two" at="two">second node</node></root>';
    $xmlDoc = new DOMDocument();
    $xmlDoc->loadXML($doc);

    $nodeList=$xmlDoc->getElementsByTagName('node');

    echo 'Current PHP version: ' . `phpversion()`."\n\n";

    //echo $xmlDoc->saveXML();

    foreach($nodeList as $node){
        echo "getting id\n";
        echo "----------\n";
        echo "\tgetAttribute('id'):".$node->getAttribute('id')."\n";
        echo "\tgetAttribute('xml:id'):".$node->getAttribute('xml:id')."\n";
        echo
"\tgetAttributeNS('xml','id'):".$node->getAttributeNS('xml','id')."\n"."\n";

        echo "\tgetAttribute('at'):".$node->getAttribute('id')."\n";
        echo "\tgetAttribute('xml:at'):".$node->getAttribute('xml:id')."\n";

        echo
"\tgetAttributeNS('xml','at'):".$node->getAttributeNS('xml','id')."\n"."\n";
    }

    //phpinfo();

?>
-----------------------------------------------------------------------------------------------------------------------------------------


Current PHP version: 5.2.1

getting id
----------
    getAttribute('id'):
    getAttribute('xml:id'):one
    getAttributeNS('xml','id'):

    getAttribute('at'):
    getAttribute('xml:at'):one
    getAttributeNS('xml','at'):

getting id
----------
    getAttribute('id'):
    getAttribute('xml:id'):two
    getAttributeNS('xml','id'):

    getAttribute('at'):
    getAttribute('xml:at'):two
    getAttributeNS('xml','at'):

Current PHP version: 5.1.6

getting id
----------
    getAttribute('id'):one
    getAttribute('xml:id'):
    getAttributeNS('xml','id'):

    getAttribute('at'):one
    getAttribute('xml:at'):
    getAttributeNS('xml','at'):

getting id
----------
    getAttribute('id'):two
    getAttribute('xml:id'):
    getAttributeNS('xml','id'):

    getAttribute('at'):two
    getAttribute('xml:at'):
    getAttributeNS('xml','at'):

Current PHP version: 5.1.4

getting id
----------
    getAttribute('id'):one
    getAttribute('xml:id'):
    getAttributeNS('xml','id'):

    getAttribute('at'):one
    getAttribute('xml:at'):
    getAttributeNS('xml','at'):

getting id
----------
    getAttribute('id'):two
    getAttribute('xml:id'):
    getAttributeNS('xml','id'):

    getAttribute('at'):two
    getAttribute('xml:at'):
    getAttributeNS('xml','at'):

---

## #29461 — Rob Richards — 2007-05-16T13:17:31+00:00

URL: https://externals.io/message/29434#29461 · In reply to: #29434

kepbepos kepbepos wrote:
> Hi all,
>
> I've some problems with getAttribute* methods. I thing it is a bug, but
> before  send it, I'd like to propose a little test to you all, just to 
> have
> a confirmation (maybe is my installation only).
PHP 5.2.x has correct behavior (see bug 38474) based on W3C specs.
http://bugs.php.net/bug.php?id=38474

Rob
