RSS 在 IE 和 Chrome 上无法显示,但在 Firefox 上可以正常显示?
我正在使用 php
和 mysql
制作rss feed
。 我从数据库中提取出版物并格式化提要数据,如下所示:
$output = "<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0' encoding='UTF-8'>
<channel>
<title>Our CareFusion Publications RSS "</title>
<link>http://www.dev.carefusion.co.uk/news/rss.php</link>
<description>This is the testing publication rss feeds</description>
<language>en-us</language>
<pubDate>{$now}</pubDate>
<webMaster>Ghazanfar Mir</webMaster>
";
然后循环遍历每个出版物:
foreach($getPublications as $publication)
{
$output .= "<item><title>{$publication['Publication_title']}</title>
<link>http://www.dev.carefusion.co.uk/news/rss.php</link>
<description>" . strip_tags($publication['Publication_summary']) . "</description>
<pubDate>" . date( "D, d M Y H:i:s T", $publication['pubdate']) . "</pubDate>
</item>";
}
$output .= "</channel></rss>";
header("Content-Type: application/rss+xml; charset=ISO-8859-1");
echo $output;
问题:
- 实际上,查询返回 8 行,但是,
rss
仅显示4、为什么? 我检查了页面的源代码,它显示了所有 8 个项目,但在浏览器上仅显示 4 个项目。 - 这 4 项在
Firefox
上显示,但在IE/Chrome
上不显示,为什么?
I am making rss feed
using php
and mysql
.
I pulled publications from database and formatted feed data as follows:
$output = "<?xml version='1.0' encoding='UTF-8'?>
<rss version='2.0' encoding='UTF-8'>
<channel>
<title>Our CareFusion Publications RSS "</title>
<link>http://www.dev.carefusion.co.uk/news/rss.php</link>
<description>This is the testing publication rss feeds</description>
<language>en-us</language>
<pubDate>{$now}</pubDate>
<webMaster>Ghazanfar Mir</webMaster>
";
Then looping through each publication:
foreach($getPublications as $publication)
{
$output .= "<item><title>{$publication['Publication_title']}</title>
<link>http://www.dev.carefusion.co.uk/news/rss.php</link>
<description>" . strip_tags($publication['Publication_summary']) . "</description>
<pubDate>" . date( "D, d M Y H:i:s T", $publication['pubdate']) . "</pubDate>
</item>";
}
$output .= "</channel></rss>";
header("Content-Type: application/rss+xml; charset=ISO-8859-1");
echo $output;
QUESTIONS:
- In actual, the query is returning 8 rows, however,
rss
is showing only 4, WHY?
I checked source code of the page it shows all 8 items but displays only 4 on browser. - These 4 items show on
Firefox
but not onIE/Chrome
, Why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已在
标记上声明了编码,该编码不是规范的一部分。这是我目前能看到的 IE/Chrome 上未显示提要的唯一原因。您能提供浏览器渲染内容的确切来源吗?还有其他原因可能会阻止它在 IE 或 Chrome 上呈现,以及为什么 Firefox 中出现的条目不超过 4 个;如果 XML 包含非法字符(例如
&
、<
或>
),则会导致浏览器停止渲染它完全。You've got the encoding declared on the
<rss>
tag, which is not a part of the specification. This is the only reason I can currently see as to why the feeds are not showing up on IE/Chrome.Can you provide the exact source of what's rendered to the browser? The is something else that could possibly be stoping it from rendering on IE or Chrome and why no more than 4 entries appear in Firefox; if the XML has an illegal character (such as
&
,<
, or>
), that would cause the browser to stop rendering it completely.