微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

simplexml_load_file():http://website.com/feed:563:解析器错误:实体“nbsp”未定义

如何解决simplexml_load_file():http://website.com/feed:563:解析器错误:实体“nbsp”未定义

我正在尝试从网站加载 XML 数据,但出现以下错误

simplexml_load_file(): http://website.com/Feed:563: parser error : Entity 'nbsp' not defined
simplexml_load_file(): 00f0i\u00f0,vi\u00f0 h\u00f6fum m\u00f3tteki\u00f0 \u00fea\u00f0.\r\n\r\n 

代码如下:

$RSS = simplexml_load_file('http://website.com/Feed');
foreach ($RSS->channel->item as $item) {
    $title = (string)trim(strip_tags($item->title));
    $title = html_entity_decode($post['title']);
    $description = (string)trim(strip_tags($item->description));
}

我无权编辑 XML 代码,那么如何解决此问题?

更新:这是 RSS 提要的第一部分

<?xml version="1.0" encoding="UTF-8"?><RSS version="2.0"
    xmlns:content="http://purl.org/RSS/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:atom="http://www.w3.org/2005/Atom"
    xmlns:sy="http://purl.org/RSS/1.0/modules/syndication/"
    xmlns:slash="http://purl.org/RSS/1.0/modules/slash/"
    >

<channel>
    <title></title>
    <atom:link href="" rel="self" type="application/RSS+xml" />
    <link></link>
    <description></description>
    <lastBuildDate>Wed,24 Feb 2021 12:12:53 +0000</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>
    hourly  </sy:updatePeriod>
    <sy:updateFrequency>
    1   </sy:updateFrequency>
    <generator></generator>

<image>
    <url></url>
    <title></title>
    <link></link>
    <width>32</width>
    <height>32</height>
</image> 
    <item>
        <title></title>
        <link></link>
        
        <dc:creator><![CDATA[]]></dc:creator>
        <pubDate>Wed,24 Feb 2021 11:00:20 +0000</pubDate>
                <category><![CDATA[]]></category>
        <guid isPermaLink="false"></guid>

                    <description><![CDATA[ [...]]]></description>
                                        <content:encoded><![CDATA[<p></p>
<p></p>
<p><strong></strong></p>
<p> <a href=""></a></p>
]]></content:encoded>
</item>

如何使用 PHP 从这段代码获取内容

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。