get google chrome to view an rss feed

爱⌒轻易说出口 提交于 2019-12-14 03:34:54

问题


I have an .php script that generates an RSS-Feed dynamically.

I want to link a .css stylesheet to this script to enable browsers that don't have a builtin RSS-viewer to display this feed. I do this with

echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n";
echo "<?xml-stylesheet type=\"text/css\" href=\"rss.css\" ?>\r\n";

as the first output commands of the .php-file.

However, browsers like chrome still don't display the feed as webpage - instead chrome shows me the code of this page.

From this tutorial, I know this is somehow possible...

http://www.petefreitag.com/item/208.cfm
http://www.petefreitag.com/rss/

how can this be done?


回答1:


You should add the header call to specify content type, like this:

header("Content-Type: application/rss+xml");

http://www.ibm.com/developerworks/library/x-phprss/ for more information.



来源:https://stackoverflow.com/questions/10114819/get-google-chrome-to-view-an-rss-feed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!