解析 RSS XML 时出现错误/警告:(
我这样做了
<blink>
$xml = file_get_contents(http://weather.yahooapis.com/forecastrss?w=12797541);
$yahoo_response = new SimpleXMLElement($xml , 0, true);
</blink>
,我得到了一个像这样的 XML 解析警告:
PHP Warning: SimpleXMLElement::__construct()
[<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]:
I/O warning : failed to load external entity "<?xml version="1.0"
.....
消息的一个重要部分是这样的:
I/O warning : failed to load external entity
我无法用这一行解析任何内容:
echo (string) $yahoo_response->rss->channel->item->title;
有谁知道如何解决这个问题或解决它?
谢谢, 亚历克斯
I did this
<blink>
$xml = file_get_contents(http://weather.yahooapis.com/forecastrss?w=12797541);
$yahoo_response = new SimpleXMLElement($xml , 0, true);
</blink>
And I got an XML parse warning like this:
PHP Warning: SimpleXMLElement::__construct()
[<a href='simplexmlelement.--construct'>simplexmlelement.--construct</a>]:
I/O warning : failed to load external entity "<?xml version="1.0"
.....
With an important part of the message being this:
I/O warning : failed to load external entity
And I could not parse anything with this line:
echo (string) $yahoo_response->rss->channel->item->title;
Does anyone know how to fix this or get around it?
Thanks,
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SimpleXMLElement()
的第三个参数指定$data
是否为 URL。你应该做或者
3rd argument of
SimpleXMLElement()
specifies if$data
is URL. You should do eitheror