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

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

 New Comment:

It works. Thanks a lot.


Previous Comments:
------------------------------------------------------------------------
[2010-04-09 04:35:33] ras...@php.net

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

node.  Try this:



print_r($xml->report);

------------------------------------------------------------------------
[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

Reply via email to