RSS

How To Display A RSS Feed Using PHP

Wed, Aug 27, 2008

PHP, Tutorials

This tutorial will show you how to make a simple RSS parsing script.

Here is the whole code, look below for a walk through of the script.

$file = file_get_contents("Feed URL");
$xml = new SimpleXMLElement($file);
foreach($xml->channel->item as $feed){
echo $feed->title.'<br>';
}

Code Breakdown

$file = file_get_contents("Feed URL");
$xml = new SimpleXMLElement($file);

This gets retrieves the RSS Feed

foreach($xml->channel->item as $feed){
echo $feed->title.'<br>';
}

This gets each item from the feed and parses them.

Demo: Link - Using the Unreal Media RSS feed

Source: Download

Rating: 5.5/10 (2 votes cast)
Share and Enjoy:
  • Digg
  • Google
  • Technorati
  • del.icio.us
  • Facebook
  • StumbleUpon
  • Furl
  • Live
  • Reddit
  • Spurl

  • Subscribe
    • XML
    • Google Reader or Homepage
    • Add to My Yahoo!
    • Subscribe with Bloglines
    • Subscribe in NewsGator Online
    • BittyBrowser
    • Add to My AOL
    • Convert RSS to PDF
    • Subscribe in Rojo
    • Subscribe in FeedLounge
    • Subscribe with Pluck RSS reader
    • Solosub
    • MultiRSS
    • R|Mail
    • Rss fwd
    • Blogarithm
    • Eskobo
    • gritwire
    • BotABlog
    • Simpify!
    • Add to Technorati Favorites!
    • Add to netvibes
    • Add this site to your Protopage
    • Subscribe in NewsAlloy
    • Subscribe in myEarthlink
    • Add to your phone
    • Get RSS Buttons

, , , ,



This post was written by:

admin - who has written 41 posts on Unreal Media.


Contact the author

6 Comments For This Post

  1. Simple Php Email Script Says:

    found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later ..

    Rating: 0.0/5 (0 votes cast)
  2. Php Echo Or Says:

    found your site on del.icio.us today and really liked it.. i bookmarked it and will be back to check it out some more later ..

    Rating: 0.0/5 (0 votes cast)
  3. Dean Says:

    Hey stumbled on this after looking on pixel2life.com, This is a good start to looking in to how to parse xml but it doesn’t really explain each line in a depth enough for me to understand how to do it, But i like this site and ill look at the others you have written thanks

    Rating: 0.0/5 (0 votes cast)
  4. Dan Says:

    Is there anyway to parse content:encoded xml tags? I’m getting php errors when I try and write $feed->content:encoded. Any ideas?

    Rating: 0.0/5 (0 votes cast)
  5. Deena Hahn Says:

    i7365jdqp6mzy80h
    ynkwkcp aztllace
    http://uoyobhhvbiz.com
    dqxsran xnkq
    http://rokkyvuyc.com
    fzkmay lqyhtz
    http://vqmllcaspia.com
    whxdjoz rsti
    http://ppfdmxm.com
    pmzegb ckcuka
    http://lamprrawpqeu.com
    aaotnt orbc
    http://hmoufqqgjjfz.com
    rochej hccxhzse
    http://dchppz.com
    zqcin hiumdq
    http://uzorfka.com
    pzsdpm tjjdsg
    http://ydkkjicxc.com
    gkqjes ailv
    http://kpdwxmn.com

    Rating: 0.0/5 (0 votes cast)
  6. Scott Says:

    Hey great code!! I used it on my site http://www.gingerlavendar.com to generate site with RSS feeds and Adsense.

    Rating: 0.0/5 (0 votes cast)

Leave a Reply