From: olivier dot bichler at laposte dot net
Operating system: Windows XP (with SP1)
PHP version: 5.0.0b2 (beta2)
PHP Bug Type: *XML functions
Bug description: getElementByTagName doesn't work properly
Description:
------------
The DOM function "getElementByTagName" doesn't work properly when it's
call from an element.
The W3C specification say "Returns a NodeList of all DESCENDANT Elements
with a given tag name, in the order in which they are encountered in a
preorder traversal of this Element tree."
But getElementByTagName return ALL elements encountered after the current
element and not only the descendant elements in the tree...
Reproduce code:
---------------
<?php
$xml = '<?xml version="1.0"?>
<config><section id="section1">
<param name="param1">value1</param>
<param name="param2">value2</param>
</section>
<section id="section2">
<param name="param3">value3</param>
</section>
</config>';
$dom = new DomDocument;
$dom -> loadXML($xml);
$params = $dom -> documentElement -> firstChild ->
getElementsByTagName('param');
foreach ($params as $param) {
echo $param -> getAttribute('name').'<br />';
}
?>
Expected result:
----------------
param1
param2
(according with the W3C specifications)
Actual result:
--------------
param1
param2
param3
--
Edit bug report at http://bugs.php.net/?id=26743&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26743&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26743&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26743&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26743&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26743&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=26743&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=26743&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26743&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26743&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26743&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26743&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26743&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26743&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26743&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26743&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26743&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26743&r=float