Neat RSS + XSL Trick

I'm such a dork sometimes. You'd figure with all the time I'm spending on XML lately, I would have thought of this myself, but I hadn't. What I'm talking about is putting an XSL Stylesheet header in your RSS documents so that when a browser like Moz or IE6 sees it, it'll render the XML instead of dumping raw tags in case you click on it.

I got this from Rafe's All About Symbian New Series 60 App Feed which shows the latest S60 applications that appear on Handango. When I clicked on it from a chat window, it rendered as readable in my browser and I was like "Huh? How'd that happen?" And was thinking embedded HTML (duh) and it took seriously, less than a second for me to think "No HTML, must be a stylesheet..." and poof there it was right at the top. I don't know why I hadn't thought about doing that to RSS feeds before! Neato!

It's as simple as hell to do, just add a XSL declaration after your initial XML header like:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="http://www.allaboutsymbian.com/rss/rss2html.xsl"?>

If you're using a decent browser, it'll pick up the XSL and format it accordingly. This is *very* cool. Having links on pages to RSS for those who have no idea what RSS is, is a real user-unfriendly thing to do. The monkies don't like when they click on links and receive a boatload of XML in their face.

Rafe claims he copied it from somewhere else, and I'll be copying it from him, so no biggie. Nice find Rafe!

-Russ

< Previous         Next >