#46048 [Opn->Bgs]: SimpleXML top-level @attributes not part of iterator

From: Date: Tue, 11 Nov 2008 10:50:33 +0000
Subject: #46048 [Opn->Bgs]: SimpleXML top-level @attributes not part of iterator
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-130873@lists.php.net to get a copy of this message
ID: 46048 Updated by: jani@php.net Reported By: php at isnoop dot net -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: Ubuntu 8.04 server PHP Version: 5.3.0alpha2 New Comment: Your xml is invalid: $ php -n t.php Warning: simplexml_load_string(): Entity: line 3: parser error : Opening and ending tag mismatch: key line 3 and name in /home/jani/src/build/php_5_3_tst/t.php on line 8 Warning: simplexml_load_string(): <key>value</name> in /home/jani/src/build/php_5_3_tst/t.php on line 8 Warning: simplexml_load_string(): ^ in /home/jani/src/build/php_5_3_tst/t.php on line 8 With non-invalid XML I get expected result. Previous Comments: ------------------------------------------------------------------------ [2008-09-10 23:58:49] php at isnoop dot net Description: ------------ The @attributes for the top-level element in a SimpleXMLElement object aren't returned as part of any iteration over the object. Reproduced in 5.3.0alpha1 as well. Reproduce code: --------------- $xml = ' <data id="1"> <key>value</name> </data> '; $obj = simplexml_load_string($xml); print_r(get_object_vars($obj)); Expected result: ---------------- Array ( [@attributes] => Array ( [id] => 1 ) [key] => value ) Actual result: -------------- Array ( [key] => value ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46048&edit=1

« previous php.bugs (#130873) next »