|
Do you want control over the way your
feed appears in the browser? Render your feed as HTML using an XML style sheet Click here to download example files. One of the annoyances of providing links to “raw” RSS feeds is that, without the aid of a feed reader, the links display as XML gibberish in the browser when users click the link to the feed. It’s true, XML is readable by humans, but most people don’t really want to see the raw XML. Fortunately, you can take control over the display of your raw RSS feed by adding an XML transformation (XSL style sheet) to the RSS feed. The XSL file transforms the feed XML into HTML which is then displayed in the browser. This technique works with most of the current breed of browsers. The XSL file is referenced in the RSS feed and can include formatting for the rendered HTML and you can even include a CSS style sheet if you’d like. The style sheet can be added to the RSS feed as illustrated below (bold text): <?XML version="1.0" encoding="utf-8"?> <?XML-stylesheet type='text/XSL' href='feedgadget.XSL' version='1.0'?> <rss version="2.0"> . . . </rss> Of course the XSL style sheet has to be placed in the appropriate directory. In the example above, the stylesheet will reside in the same location as the feed. And, one caveat to using an XSL style sheet is that the feed must be well formed. One thing to note: Firefox converts XML entity reference characters, such as “<” to the appropriate text equivalent; however, the resulting HTML tags are displayed as text. To overcome this problem, the XSL file can reference a Java script file named disableOutputEscaping.js that will correct the problem so that text is displayed without HTML tags (see the “Attributions” section below). Some very cool and amazing things can be done with the combination of RSS, XSL and CSS. Take a look at a FeedBurner feed sometime and browse their XSL file and CSS style sheets. They’ve done some amazing things with their style sheets. Note: IE7 automatically converts RSS feeds into HTML. Attributions: The feedgadget.xsl file was based on a file I downloaded from an article on the 4guysfromrolla Web site. The XSL file makes use of a Java script file named disableOutputEscaping.js that was created and released into the public domain by Sean M. Burk. |