5-second RSS parser w/ simpleXML

During Rasmus’s talk last week at the php|works conference, he showed how easy it is to parse XML in PHP 5, using simpleXML. In his example, he used the Flickr public photo RSS feed, to parse and output. A lot of people don’t know about this feed, which gets updated the moment a new photo gets uploaded. Furthermore, a lot of people upload their personal photos, and make them private after their uploaded. Click here to see it in action. Here are the 2 lines of code:

Code:
<?php
    $url = 'http://www.flickr.com/services/feeds/photos_public.gne';
    foreach(simplexml_load_file($url)->entry as $it) echo $it->content;
?> 

Be sure to mark you photos as private before you upload them..

Related Articles:

Follow me on Twitter!

Your Ad Here

Leave a Reply

Line and paragraph breaks automatic.
XHTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>