Friday, June 12, 2009

How To Read RSS Using PHP

Here is the simple code to read RSS Feeds using php with simpladxml_load_string function.

CODE:
1 :  <?php
2 :       $displayItems = 5;
3 :       $itemCounter = 0;
4 :       $rss = simplexml_load_file("http://put here url of RSS Feed");
5 :       foreach($rss->channel->item as $feeds){
6 :            $itemCounter++;
7 :            echo '<li><a href="'.$feeds->link.'">'.$feeds->title.'</a><br /><br />';
8 :            if($itemCounter==$displayItems)break;
9 :       }
10 :  ?>

No comments:

Post a Comment