View XKCD Atom Feed Raw, to Reveal ALT Text

Do you like the web comin xkcd? Have you noticed the alt and title attributes on the images that contain a sort of second punch line? Do you like to read xkcd in a browser such as Opera Mini that doesn't have an easy way to let you read the alt text?

Well, then this script is for you!

file: xkcd-rss-raw.php

<?php
 
header("Content-type: text/plain");
 
echo
"Here is the contents of the XKCD Atom feed, so you can see\n" .
"the ALT text in browsers that don't support it.\n";
 
$text = file_get_contents("http://xkcd.com/atom.xml");
$text = eregi_replace("<\?xml.*\?>\n", "", $text);
$text = ereg_replace("<", "\n<", $text);
$text = ereg_replace(" alt=\"", "\nalt=\"", $text);
$text = ereg_replace(" title=\"", "\ntitle=\"", $text);
echo $text;
?>

See it in action here: xkcd rss feed as raw text
(Bookmark it for yourself from this url if you'd like.)

It's not pretty, but it gets the job done in a handful of lines of code, so I'm satisfied.

 
software/xkcd_raw_rss.txt · Last modified: 2009/02/10 12:12 by brendan
© 2009 Brendan Kidwell. Glump.net web pages are licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
This web site is built upon DokuWiki.