这个问题是对此问题的后续跟进:
get google chrome to view an rss feed
我从这个页面复制了源代码(希望这对网站所有者来说是好的):
http://www.petefreitag.com/rss/.
我从所有引号中逃脱并制作了一个PHP文件.该文件如下所示:
<?PHP
header('Content-Type: application/RSS+xml');
echo "<?xml version=\"1.0\" ?>
<?xml-stylesheet type=\"text/css\" href=\"http://www.petefreitag.com/RSS/simple_style.css\" ?>
<RSS version=\"2.0\">
<channel>
<title>Pete Freitag's Homepage</title>
<link>http://www.petefreitag.com/</link>
<description>Covering ColdFusion, Java, Web Development, and other topics</description>
<language>en-us</language>
<lastBuildDate>Fri, 23 Mar 2012 18:57:00 GMT</lastBuildDate>
<ttl>45</ttl>
<item>
REST OF THE SOURCE CODE
</RSS>
";
?>
在这里你可以看到结果:
http://web.student.tuwien.ac.at/~e0250890/rsstest/test.php
但是,在http://www.petefreitag.com/rss/ chrome上将页面视为RSS Feed,在我的示例中,它仅显示源代码.
有什么区别,我如何强制chrome以RSS Feed的形式查看页面?
解决方法:
尝试将标题更改为application / xml
<?PHP
header('Content-Type: application/xml');
echo file_get_contents('http://web.student.tuwien.ac.at/~e0250890/RSStest/test.PHP');
?>
Mozilla接受一系列标题
text / xml,application / xml,application / RSS xml,application / atom xml
但似乎chrome只接受text / xml或application / xml
不是100%肯定为什么,也许你应该用google; p