【发布时间】:2012-10-29 09:02:38
【问题描述】:
我有一个类似下面的功能并收到错误String could not be parsed as XML
$category_feed_url = "http://www.news4u.com/blogs/category/articles/feed/";
$file = file_get_contents($category_feed_url);
$xml = new SimpleXMLElement($file);
foreach($xml->channel->item as $feed)
{
echo $feed->link;
echo $feed->title;
...
为什么会出现这个错误。
【问题讨论】:
-
传递给 SimpleXMLElement 的字符串应该是格式良好的 xml。您的 URL 中的内容是纯 HTML。
标签: php xml apache xml-parsing simplexml