1
我想通過一個xml文件解析具有一大堆子屬性。解析XML並忽略特殊字符w/php
有它和我的PHP錯誤日誌一些特殊字符來顯示這個
[23-Jun-2015 17:56:11 America/Denver] PHP Warning: simplexml_load_file(): anime.xml:1: parser error : Start tag expected, '<' not found in /home/residez3/public_html/aresrelease/db/test.php on line 14
[23-Jun-2015 17:56:11 America/Denver] PHP Warning: simplexml_load_file(): 1 in /home/residez3/public_html/aresrelease/db/test.php on line 14
[23-Jun-2015 17:56:11 America/Denver] PHP Warning: simplexml_load_file():^in /home/residez3/public_html/aresrelease/db/test.php on line 14
[23-Jun-2015 17:56:20 America/Denver] PHP Warning: curl_setopt() expects parameter 2 to be long, string given in /home/residez3/public_html/aresrelease/db/test.php on line 6
XML https://pastebin.com/13hQAP2c
我想拉某些兒童和嵌套的屬性,從內到顯示在頁面上。到目前爲止,我只能夠顯示整個XML文件,而不是抓住一個特定的孩子。
$url = "http://cdn.animenewsnetwork.com/encyclopedia/api.xml?anime=16252";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETRUNTRANSFER, ture);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, ture);
$opt = curl_exec($ch);
$handle = fopen("anime.xml", "wb");
fwrite($handle, $opt);
fclose($handle);
$xml = simplexml_load_file('anime.xml');
echo $xml->anime->attributes()->id;