ID:               41976
 Updated by:       [EMAIL PROTECTED]
 Reported By:      stefan dot priebsch at e-novative dot de
-Status:           Open
+Status:           Bogus
 Bug Type:         JSON related
 Operating System: WinXP
 PHP Version:      5.2.3
 New Comment:

  var_dump((string) $xml);
  var_dump(json_encode($xml)); <-- you have to cast it to string
explicitly, otherwise json_encode() will encode the object itself, not
it's string representation.


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

[2007-07-12 07:39:30] stefan dot priebsch at e-novative dot de

Description:
------------
When json_encoding (Simple)XML data, CDATA sections are ignored.

Reproduce code:
---------------
  $xml = new SimpleXMLElement('<?xml version="1.0"
encoding="UTF-8"?><test>test</test>');
  var_dump((string) $xml);
  var_dump(json_encode($xml));

  $xml = new SimpleXMLElement('<?xml version="1.0"
encoding="UTF-8"?><test><![CDATA[test]]></test>');
  var_dump((string) $xml);
  var_dump(json_encode($xml));


Expected result:
----------------
string 'test' (length=4)

string '{"0":"test"}' (length=12)

string 'test' (length=4)

string '{"0":"test"}' (length=12)


Actual result:
--------------
string 'test' (length=4)

string '{"0":"test"}' (length=12)

string 'test' (length=4)

string '{}' (length=2)



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


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

Reply via email to