首页 > 解决方案 > 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.

标签: phpxml

解决方案


推荐阅读