php - PHP simplexml_load_file and LIBXML_NOENT
问题描述
I am reading in an XML file that contains in it
<description>Q&A for March</description>
This breaks the php script that I have to parse the XML file and generate an HTML page.
The command I am using to read the file is
$rssfeed = simplexml_load_file($rss_array[$i], "SimpleXMLElement", LIBXML_NOENT);
I have tried it with NULL in the second field and without either the second or third field, but nothing works.
There error returned is Warning: simplexml_load_file(): feed.xml:2251: parser error : EntityRef: expecting ';' in /volume1/web/podcasts/podfeed.php on line 19 Warning: simplexml_load_file(): Q&A for March
I do not have control over the XML output (it is a podcast feed) and the XML is parsed properly by various podcast applications, so “It’s your problem”.
This is not a duplicate, as the XML file itself does not generate any errors. As I specifically said in the question, the podcast apps process the file fine. It is PHP and only PHP that complains. The question is how to get PHP to fix the input as it gets it instead of just crashing.
解决方案
推荐阅读
- excel - 如何在Excel中突出显示时间间隔之间的第一条记录?
- apama - 解析具有 xml 属性的 json 响应的问题
- sql - 无法获得 Sum 作为其要求应用组的依据
- php - 描述模拟重载函数的最佳注释是什么?
- ansible - 为什么我无法 Ansible ping 我的测试服务器?
- reactjs - 使用来自 reactjs 应用程序的 ldap 登录失败
- android - iOS 将 Cordova 应用程序作为 web 视图嵌入到另一个应用程序中
- perl - 服务器没有安装 Digest::SHA 'hmac_sha256_base64',我可以使用 Digest::HMAC_SHA1 'hmac_sha1' 代替吗?
- reactjs - 无法使用 Typescript 和 React 将列表中的项目传递给函数
- laravel - 为什么 Repository 接口绑定到服务容器