RSS

Slightly More Advanced RSS Parsing

Sat, Sep 13, 2008

PHP, Tutorials

RSS Logo

I made a tutorial a while back which parsed RSS feeds however it was really simple, in fact too simple…So here is a completely new script which parses the feeds in a completely different way.

So heres a walk-through of the script…

Firstly we need to represent the feed as an xml document. Using DOMDocument…More information here

$xmldoc = new DOMDocument();

Now we need to load the RSS Feed.

$xmldoc->load('RSS Feed Address');

Now the feed is loaded we need to make sure that each item in the feed is loaded individually.

foreach ($xmldoc->getElementsByTagName('item') as $feeditem) {

Now we need to show the feed. This will also show it as a link which the previous script didn’t do.

echo "getElementsByTagName('link')->item(0)->nodeValue . "\">“;
echo $feeditem->getElementsByTagName(’title’)->item(0)->nodeValue . “
\n”;
}

That snippet of code looks complicated however if you break it down its very simple. It’s just a hyperlink in HTML with PHP in the middle.

Demo - Using The Flick Zone Feed

Heres a full Source code for you copy and pasters out there….

load('RSS Feed Address');
foreach ($xmldoc->getElementsByTagName('item') as $feeditem) {
echo "getElementsByTagName('link')->item(0)->nodeValue . "\">";
echo $feeditem->getElementsByTagName('title')->item(0)->nodeValue . "\n";
}
?>
Rating: 0.0/10 (0 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

5 Comments For This Post

  1. aashwin Says:

    Demo Doesnt work

    Rating: 0.0/5 (0 votes cast)
  2. Admin Says:

    Ok fixed now. I replaced the feed with one from another site.

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

    Tired of writing lines of lines with source code each time you are coding a website? Feel like just copying and pasting but afraid that you might end up getting sued?
    No more worries, WebCodeBase is the website you’ve been looking for!
    Here you can find source code that you can copy without any issues at all, we guarantee that you will not get sued for using the code we put on this website. So what are you waiting for?

    http://www.webcodebase.com

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

    Sunday In searching for sites related to web hosting and specifically hosting in php script web, your site came up.

    Rating: 0.0/5 (0 votes cast)
  5. Php Web Page Hosting 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)

Leave a Reply

PHP parsed this page in 1227225388.93 seconds.