php - 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 从这段代码中获取内容?
解决方案
推荐阅读
- c# - C# 不强制类实现公共接口
- javascript - 多个组件的 useEffect、useState 和 useContext 的 React Hooks 生命周期是什么?
- angular - 我应该如何将 datetime json 字符串属性映射到 TypeScript 日期类型?
- oracle - “CLOB”列上的行锁争用
- python - sum([.25,.35,.3,.1,0]) 给出 0.999999(9) 而不是 1。为什么?
- scala - for后如何避免平面图
- c - 输入的数字字符
- python - 无法安装 nlopt python 模块
- reactjs - 如何使用前一个操作的返回结果链接 redux 操作?
- python - Python:用整数键解包字典?