Tiffany B. Brown

a mish-mosh of stuff

Now with (validated!) RSS!

I’ve been meaning to create an RSS feed for my site for quite some time now. Today, I jumped in and did it.

I confess I cheated a bit by hijacking the basic code from a Search Engine Watch article on creating RSS feeds.

But I still had to figure out how to automate the updating of the feed. Enter my old friend PHP and the magic Apache directive AddType.

I created a new directory (feeds), then created an .htaccess file in that directory with the following line: AddType application/x-httpd-php .xml. That lets the server know to parse X M L files in that directory as PHP files.

A few database calls later, and I’ve got a dynamically-generated RSS feed available for your pleasure.

You will need an aggregator, however. If you’re on a Windows box with Mozilla installed, I’d like to suggest Newsmonster. You’ll also need the latest version of Java.

Or try a service like Kinja

UPDATE: Now your browser will recognize it as an XML document, and your news reader will recognize it as a valid RSS feed. I had to modify the code a smidge, adding header("Content-type: text/xml"); to the script, stripping out HTML tags, and converting special characters.

Comments are closed.