Docunext


RSS2JSON

November 19th, 2010

The other day I was about to integrate an RSS feed onto a web page using jQuery.

To ease the way in which jQuery accessed the feed, I decided to write a quick fopen proxy, and then I figured... hey, why not convert this to JSON while I'm at it?

I did a quick search for "convert rss to json with php", and turned up a bunch of stuff that wasn't what I was looking for. So I opted out of the lazy web approach and decided to think for a moment... aha, this is much easier!

$json = json_encode(simplexml_load_string($rss));

Wow. Who says you can't do useful stuff with PHP in one single line??

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022