drnmslpz42661 2015-06-24 00:06
浏览 173

解析XML并忽略特殊字符w / php

I am trying to parse through an xml files that has a ton of child attributes.

There are some special characters in it and my php errorlog shows this

[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

I am trying to pull certain child and nested attributes from within to display on a page. So far I am only able to display the whole xml file and not grab a specific child.

$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;
  • 写回答

1条回答 默认 最新

  • drg5577 2015-06-24 00:23
    关注

    I feel really dumb now, I figured out that my xml file wasn't being written to.

    评论

报告相同问题?

悬赏问题

  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM