问题
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