# dom strange behaviours

- Thread: https://externals.io/message/29433
- Original archive: https://news-web.php.net/php.internals/29433
- Started by kepbepos kepbepos on 2007-05-15T09:44:26+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

---

## #29433 — kepbepos kepbepos — 2007-05-15T09:44:26+00:00

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

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'):

---

## #29456 — Marco Kaiser — 2007-05-16T11:03:11+00:00

URL: https://externals.io/message/29433#29456 · In reply to: #29433

hi,

looks like you have an problem or this has been fixed with php 5.2.2.
Or can you maybe explain what you expect?

my results are:

Current PHP version: 5.2.2

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'):
