使用php解析XML并忽略特殊字符

使用php解析XML并忽略特殊字符,php,xml,parsing,simplexml,Php,Xml,Parsing,Simplexml,我试图通过一个包含大量子属性的xml文件进行解析 其中有一些特殊字符,我的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 li

我试图通过一个包含大量子属性的xml文件进行解析

其中有一些特殊字符,我的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文件没有被写入。

我现在感觉很笨,我发现我的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;