Bug #51517 [Opn]: Node attributes lost when it has both attributes and value

[email protected] Fri, 9 Apr 2010 04:35:33 +0200 (CEST)
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at http://bugs.php.net/bug.php?id=51517&edit=1

 ID:               51517
 Updated by:       [email protected]
 Reported by:      zhangxc83 at sohu dot com
 Summary:          Node attributes lost when it has both attributes and
                   value
 Status:           Open
 Type:             Bug
 Package:          SimpleXML related
 Operating System: Linux 2.6.18-92.el5
 PHP Version:      5.3.2

 New Comment:

They are not lost.  It is just a deficiency in print_r walking from the
root 
node.  Try this:

print_r($xml->report);


Previous Comments:
------------------------------------------------------------------------
[2010-04-09 04:31:01] zhangxc83 at sohu dot com

Description:
------------
AS Test Scripts below:

Test script:
---------------
$xml = <<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<root>
<report id="testid">test value</report>
</root>
EOT;

$xml = new \SimpleXMLElement(trim($xml));
print_r($xml);


Expected result:
----------------
.SimpleXMLElement Object
(
    [report] => .SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [id] => testid
        )

    [0] => test value
)
)



Actual result:
--------------
.SimpleXMLElement Object
(
    [report] => test value
)



------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=51517&edit=1