I’m trying to transcode xml to json and it’s not working, online services recode my xml without problems, for example this one .

My code is:

<?php //подгружаю xml файл $xml = simplexml_load_file('https://accounts.clickbank.com/api2/marketplace'); //перевожу его из xml в json $json = json_encode($xml); //формирую массив из json $data = json_decode($json,TRUE); //$data = json_encode($jsonString, TRUE); //проверяю как сформировался массив var_dump($data); ?> 

With $data = json_decode($json,TRUE); bool error (false)

for $data = json_encode($jsonString, TRUE); error string (4) "null"

Please help me figure it out.

  • one
    The json_encode argument should be in utf-8 encoding - Alexander Chernin
  • 2
    json_last_error_msg () - Total Pusher
  • utf-8 added, did not help or not so added $json = json_encode($xml, 'UTF-8', true); NULL Another added header('Content-Type: application/json; charset=utf-8'); - MicroRu
  • one
    var_dump($xml); - u_mulder
  • var_dump ($ xml); gives bool (false) - MicroRu

0