How to Display RSS Feeds from other websites in your PHP Page

0

Posted on : 05-08-2011 | By : | In : PHP, RSS Feeds

RSS stands for Really Simple Syndication and Atom are two famous feed format.

If you open any RSS Feed page, first line starts with < ?xml … ?> and then and at the end .
So anything inside and is feed data.
Every content is placed under .
So all we need to do is read information inside and display it.

Here is a sample program that does it.

/* Our Code Starts Here */

//Enter the Feed url as parameter to function

$xml = simplexml_load_file(”http://www.vaseemansari.com/blog/feed”);

//To check if the read document is a rss feed

if($xml->channel->item)
{
$contents = $xml->channel->item;
foreach($contents as $content)
{
echo $content->title;
echo $content->description;
}
}
else
{
echo “Invalid RSS Format”;
}

/* Our Code Ends Here */

I will provide you the complete zip file of the php code very soon. Please be in touch and keep on reading.

Tags: , ,

If you liked this post you may want to Subscribe to Latest CodeMasterz buzz about Tech Tips, Worpdress Tips and more updates in your inbox.

Enter your email address:     Delivered by FeedBurner

Post a comment