php xml转换json

152 阅读1分钟

如果你使用 curl 获取的 simplexml_load_string() 函数把 XML 字符串载入对象中。

$xml = simplexml_load_string($xmlStr);  
$json = json_encode($xml);