#27139 [Com]: can't iterate thru simplexml_element objects in normal ways
| From: | adam at trachtenberg dot com | Date: | Wed, 04 Feb 2004 04:55:32 +0000 |
| Subject: | #27139 [Com]: can't iterate thru simplexml_element objects in normal ways | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-54366@lists.php.net to get a copy of this message | ||
ID: 27139
Comment by: adam at trachtenberg dot com
Reported By: kennyt@php.net
Status: Open
Bug Type: *XML functions
PHP Version: 5CVS-2004-02-03 (dev)
New Comment:
No. You need to use foreach() or the iterator magic
won't work.
Previous Comments:
------------------------------------------------------------------------
[2004-02-03 22:16:05] kennyt@php.net
Description:
------------
We should be able to use normal array iteration
techniques when going through such pseudoarray
structures in simplexml elements, right?
Reproduce code:
---------------
$xml = simplexml_load_string(
'<a>
<b></b>
<b></b>
<b></b>
</a>');
while(list($foo, $bar) = each($xml->b)) {
echo '"' , $foo , '" - "', $bar , '"' , chr(10);
}
--OR--
for($i = 0; $i < count($xml->b); ++$i) {
echo '"' , $i , '" - "', $xml->b[$i] , '"' ,
chr(10);
}
Expected result:
----------------
[3 lines of output]
--OR--
"0" - ""
"1" - ""
"2" - ""
Actual result:
--------------
[no output]
--OR--
"0" - ""
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27139&edit=1