doune1000 2012-04-13 17:56
浏览 25
已采纳

使chrome显示rss feed(2)

This question is a follow-up on this one: get google chrome to view an rss feed

I copied the source code from this page (hope this is ok for the site-owner):
http://www.petefreitag.com/rss/.
I escaped all quotes and made a php file out of it. The file looks like this:

<?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>
";
?>

Here you can see the result: http://web.student.tuwien.ac.at/~e0250890/rsstest/test.php

However, on http://www.petefreitag.com/rss/ chrome views the page as rss feed, in my example it shows just the source code.

What is the difference and how can I force chrome to view the page as rss feed?

  • 写回答

2条回答 默认 最新

  • douying7289 2012-04-13 18:04
    关注

    Try changing the header to application/xml

    This worked for me by changing the header:

    <?php 
    header('Content-Type: application/xml');
    echo file_get_contents('http://web.student.tuwien.ac.at/~e0250890/rsstest/test.php');
    ?>
    

    Mozilla accepts a whole range of headers

    text/xml,application/xml,application/rss+xml,application/atom+xml

    But it seems chrome accepts only text/xml or application/xml

    Not 100% sure why, perhaps you should take it up with google ;p

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀