From:             me at gowthams dot in
Operating system: All
PHP version:      5.4.11
Package:          DOM XML related
Bug Type:         Bug
Bug description:Accessing childNodes of DOM element fails

Description:
------------
I found this error while trying to parse an ordered list. When I access the
firstChild or the lastChild of a DOM object that is in turn derived from
another DOM object , the value is printed perfectly. 

However, when I try to access childDomObject->childNodes->item(0), the code
fails.

Test script:
---------------
<?php

$html_data = 
'<html><body>
<ol>
    <li><strong>Question 1</strong> Answer1</li>
    <li><strong>Question 2</strong> Answer2</li>
</ol>
</body></html>';

$doc = new DOMDocument();
$doc->loadHTML($html_data);
$xpath = new DOMXPath($doc);

$ols = $xpath->query('//ol');
$ol = $ols->item(0);
$lis = $ol->childNodes;

foreach ($lis as $li) {
//echo $li->firstChild->nodeValue."<br />";
//echo $li->lastChild->nodeValue."<br />";
echo $li->childNodes->item(0)->nodeValue."<br />";
}

Expected result:
----------------
Question 1 Answer1<br />
Question 2 Answer2<br />

Actual result:
--------------
Question 1<br />


-- 
Edit bug report at https://bugs.php.net/bug.php?id=64104&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64104&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64104&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64104&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64104&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64104&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64104&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64104&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64104&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64104&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64104&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64104&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64104&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64104&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64104&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64104&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64104&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64104&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64104&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64104&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64104&r=mysqlcfg

Reply via email to