Webmaster Forum  

Go Back   Webmaster Forum > Website Design Forum > Website Design Forum
User Name
Password
Register FAQ Members List Calendar Transactions Store Search Today's Posts Mark Forums Read


A Simple RSS Feed Phraser in PHP

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-10-2005, 09:10
admans
Senior Member


Join Date: Jul 2005
Posts: 248
Trader Rating: (0)
Points: 22 (Donate)
5 F$/Referral Refer Friends
admans is on a distinguished road
Default A Simple RSS Feed Phraser in PHP

A Simple RSS Feed Phraser in PHP

Heres a simple RSS Feed Phraser function. Its simple and effective function. All you need to do is add it to the page you wish to display the feed.

If you want to show / display the feed all you need to do is call up the function using:
PHP Code:
 showFeed($url,$count); 



The $variables can be used to define a few options:

$url = the url of the rss feed (e.g. http://slashdot.org/slashdot.rdf)
$count = the number of titles and descriptions to display (e.g. 5)

Using this function you can display more than one rss feed in one page / file, without constantly rewriting out all the code to display the feed. The function:
PHP Code:
 function showFeed($url,$count)
    {
            
//* get the xml file
            
$xml simplexml_load_file($url);
            
//* phrase all the data from the xml so we can display it
                
for ($x 0$x $count$x++) {
                 
//* this bits for if its an rss 1 feed
                
if (isset($xml->item)) {
                    
$item $xml->item[$x];
                }
                
//* this bits for 0.91 rss feeds
                    
elseif (isset($xml->channel->item)) {
                    
$item $xml->channel->item[$x];
                }
                
//* show the headline and the description
                    
echo "<a href=\"$item->link\">$item->title</a><br>$item->description<br><br>";
            }
            
//* reset variables
            
unset($xml);
            unset(
$item);
    
//* close the function loop
    



Enjoy!
__________________

http://img76.imageshack.us/img76/6450/sc2but4ng.gif | http://img495.imageshack.us/img495/...ogorwtan0je.gif | <a href="http://webtools.sc2.info"><img src="http://img129.imageshack.us/img129/8682/sc2webtan7ju.gif" border="1" width="100" alt="Free Webtools for all" /></a> | <a href="http://www.indexrated.com"><img src="http://img398.imageshack.us/img398/4813/listed1pb.gif" border="1" width="100" alt="Index Rated Directory - Rating Quality Sites" /></a>

Get all Games,Apps and Wallpapers Nokia, Samsung and Sony Erricson!!

admans is offline
Reply With Quote
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Resources : | Advertise at FHF | itextLink.com| Reseller Hosting| TextDot| iNamePros| Any Webmaster| Web Host| Dep3|


All times are GMT -4. The time now is 06:47.


Powered by: vBulletin
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.