【发布时间】:2017-10-20 08:33:01
【问题描述】:
在问这个问题之前,我尝试了一些从 URL 加载数据 xml 的方法,但都失败了。同样在 XML url 中有一些特殊字符。这是错误
Warning: simplexml_load_file(): I/O warning : failed to load external entity " " in D://....;
这是我的代码:
$url = 'http://website.com?xml¶m1=1¶m2=2';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url); // get the url contents
$data = curl_exec($ch); // execute curl request
curl_close($ch);
$xml = simplexml_load_string($data);
$json = json_encode($xml);
echo $json;
感谢大家的帮助
【问题讨论】: