ID:               45878
 Updated by:       [EMAIL PROTECTED]
 Reported By:      chenming522 at gmail dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         JSON related
 Operating System: windows xp
 PHP Version:      5.2.6
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:
------------------------------------------------------------------------

[2008-08-21 06:07:43] chenming522 at gmail dot com

Description:
------------
Hi:
   I am a new gur for PHP program, Recently when I write a program that
use php function json_encode() to translate a simpleXML object into json
code, I found the attributes of the XML leafage node was lose.
   Wait to solve :).
Thank you.

Reproduce code:
---------------
<?
        $xml_str = "<root><node attr='node attribute'>node
value</node></root>";
        $xml_obj = simplexml_load_string($xml_str);
        $json = json_encode($xml_obj);
        echo $json;     // so where is node's attribute
        echo "\n=======================================\n";
        $xml_str = "<root><node attr='node attribute'></node></root>";
        $xml_obj = simplexml_load_string($xml_str);
        $json = json_encode($xml_obj);
        echo $json;     // found it, but why?
?>

Expected result:
----------------
{"node":"node value"}
=======================================
{"node":{"@attributes":{"attr":"node attribute"}}}

Actual result:
--------------
inlude node's value and attributes


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


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

Reply via email to