How to display Atom/RSS feeds in browser with custom XSLT?

前端 未结 3 953
梦谈多话
梦谈多话 2021-01-06 16:43

Back in about 2006, I wrote a nice XSLT that transformed my RSS feeds into custom HTML. That way if a user clicked from a browser it would display as a simple page rather th

相关标签:
3条回答
  • 2021-01-06 17:25

    It is now default behaviour for most browser to apply their own XSLT to any Atom/RSS feed they come across, very annoying. A feed is identified through the application/atom+xml mime type for Atom and application/rss+xml for RSS

    You used to be able to circumvent this by filling the first 512 bytes of the feed with crud in the form of a comment. This would throw off the feed sniffing of the browser and allow you to apply your own XSL Stylesheet. This has worked for years for me but with IE8 this behaviour has gone out of the window and the 512 bytes comment doesn't work anymore. I have now switched over to server side processing but I still lament this decision from browser makes.

    0 讨论(0)
  • 2021-01-06 17:27

    Chrome appears to only apply the XSLT processing instruction if the Content-Type for the feed response is set to XML, not Atom.

    This displays XSLT in Chrome:

    Content-Type: application/xml
    

    This does not display any styling (which is technically the more correct type):

    Content-Type: application/atom+xml
    
    0 讨论(0)
  • 2021-01-06 17:33

    I'm not aware of a way to fool IE & FF & Safari's automatic display of RSS/Atom feeds, but in Chrome the XSLT is correctly applied via the xml-stylesheet processing instruction; here is an example from the Randonneur Group pool at flickr.

    0 讨论(0)
提交回复
热议问题