dom strange behaviours

php.internals

kepbepos kepbepos

19 years ago
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'):

Marco Kaiser

19 years ago
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'):