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条)

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 ARIMA模型时间序列预测用pathon解决
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序,怎么查看客户esp32板子上程序及烧录地址
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)