ID: 25640 Comment by: tim at timcrider dot com Reported By: tater at potatoe dot com Status: Assigned Bug Type: XML related Operating System: * PHP Version: 5CVS-2003-09-23 (dev) Assigned To: sterling New Comment:
I have been able to produce a similar problem, but I'm not sure if it's exactly the same bug or a variant of this one. -----[ XML Field ]----- <?xml version="1.0" encoding="UTF-8"?> <test> <fields> <myField>a</myField> <myField>b</myField> <myField>c</myField> </fields> </test> -----[ Script ]----- #!/usr/local/bin/php -q <?php $sx = simplexml_load_file("_example.xml"); print_r($sx); for ($i = 0; $i < count($sx->fields->myField); $i++) { $v = $sx->fields->myField[$i]; print "True Value: {$v}\n"; $tmp[] = $v; $tmp2[] = "$v"; } print "Trying to view 'tmp' array:\n\n"; print_r($tmp); print "Trying to view 'tmp2' array:\n\n"; print_r($tmp2); ?> -----[ Output ]----- simplexml_element Object ( [fields] => simplexml_element Object ( [myField] => Array ( [0] => a [1] => b [2] => c ) ) ) True Value: a True Value: b True Value: c Trying to view 'tmp' array: Array ( [0] => simplexml_element Object ( ) [1] => simplexml_element Object ( ) [2] => simplexml_element Object ( ) ) Trying to view 'tmp2' array: Array ( [0] => a [1] => b [2] => c ) -----[ PHP Version Info ]----- PHP 5.0.0b2 (cli) (built: Dec 7 2003 18:04:51) Copyright (c) 1997-2003 The PHP Group Zend Engine v2.0.0-dev, Copyright (c) 1998-2003 Zend Technologies with Turck MMCache v2.4.6, Copyright (c) 2002-2003 TurckSoft, St. Petersburg, by Dmitry Stogov I tried the latest CVS, at the time of this posting, and it would not build because of a mysqli compile problem. Previous Comments: ------------------------------------------------------------------------ [2003-09-23 21:25:25] tater at potatoe dot com Description: ------------ I guess this is related to the recent toString() stuff - simplexml_element object properties can't be printed or assigned, they all come out as 'Object #x'. the string values turn into empty simplexml_element objects. Reproduce code: --------------- <?php $xml = '<wrapper><foo>s1</foo><bar>s2</bar><bar>s3</bar></wrapper>'; $t = simplexml_load_string($xml); var_dump($t,$t->foo,$t->bar); ?> Expected result: ---------------- object(simplexml_element)#1 (2) { ["foo"]=> string(2) "s1" ["bar"]=> array(2) { [0]=> string(2) "s2" [1]=> string(2) "s3" } } string(2) "s1" array(2) { [0]=> string(2) "s2" [1]=> string(2) "s3" } Actual result: -------------- object(simplexml_element)#1 (2) { ["foo"]=> string(2) "s1" ["bar"]=> array(2) { [0]=> string(2) "s2" [1]=> string(2) "s3" } } object(simplexml_element)#2 (0) { } array(2) { [0]=> object(simplexml_element)#3 (0) { } [1]=> object(simplexml_element)#4 (0) { } } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=25640&edit=1