|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-09-10 23:58 UTC] 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
)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 22:00:01 2025 UTC |
$ php t.php Array ( [@attributes] => Array ( [id] => 1 ) [key] => value ) [jani@localhost ~]$ php -v PHP 5.2.7-dev (cli) (built: Oct 9 2008 16:54:00) (DEBUG) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies So still no bug. If you experience this even with proper XML, I guess it's your libxml that is a buggy version. (my PHP is build with libxml 2.7.2)I have tested this with the two new PHP releases on yet another server: 5.3.0alpha3 Fails: [] [ian@ianm:~/src/php-5.3.0alpha3/sapi/cli] ./php -v;./php ~/sandbox/bug46048.php PHP 5.3.0alpha3 (cli) (built: Dec 4 2008 17:18:52) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2008 Zend Technologies Array ( [key] => value ) 5.2.8 Passes: [] [ian@ianm:~/src/php-5.2.8/sapi/cli] ./php -v;./php ~/sandbox/bug46048.php PHP 5.2.8 (cli) (built: Dec 8 2008 17:34:28) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies Array ( [@attributes] => Array ( [id] => 1 ) [key] => value )I am experiencing the same problem on 5.3. The code used is the same used above. shephezj@ursa-minor:~/php5/sapi/cli$ ./php -v; ./php ~/code/scrap/php/bugs/46048.php PHP 5.3.0alpha4-dev (cli) (built: Jan 15 2009 17:22:45) Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies Array ( [key] => value )