Parsing RSS FEED with PHP | Web Programming Tutorial

Parsing RSS FEED with PHP

Published Date: October 22, 2013 |
Published Time: 12:45 am |

RSS (Rich Site Summary) often  dubbed Really Simple Syndication is  a format for delivering regularly changing web content. Many news-related sites, weblogs and other online publishers syndicate their content as an RSS Feed to whoever wants it and they enable usually different types of feeds for their users.

RSS solves a problem for people who regularly use the web. It allows you to be updated  by retrieving the latest content from the sites you are interested in.

Today I will discuss about how to get the feed of a website and can use your own website for update news, tutorial or notice.It’s very simple. It’s is similar as xml file read.

Most of the website have RSS FEED option with a symbol like  and a link. we need to go to the link. And show the view page source  to confirm that what information have been published  for user.Then we can collect the information and display in our website easily.

Now I am going to describe with an example :

  1. Go to any website which has RSS FEED option. (http://www.webprogrammings.net/) .In this example we can see the rss link at the bottom of the page, different site have in different positionxml1
  2. Click on RSS FEED ‘s Link and you can see a page likexml3
  3. Copy the link from address bar. Then see the page ‘view page source’ to get idea of what tag is used to share this information. Or we can get it by php code, which I will show u later.Ok , now we need to grab this information by php. We can do it simply what we do for xml file read. From Page view source we will find that, the file contains ,,,, tags. So we will get the title of the tutorial, link of the tutorial, publishing date time and brief descriptionNow to get the content: Create a file named like rss_grab.php.Write this code.
    Output

    Title is :XML file create with PHP containing Dynamic data Link is : http://www.webprogrammings.net/tutorial/individual_topic/7
    Title is :XML Read and Write From Beginning Link is : http://www.webprogrammings.net/tutorial/individual_topic/6
    Title is :Page not refresh after back button Click Link is : http://www.webprogrammings.net/tutorial/individual_topic/5
    Title is :Remote Database Access Link is : http://www.webprogrammings.net/tutorial/individual_topic/4
    Title is :Execute PHP code from the command line Link is : http://www.webprogrammings.net/tutorial/individual_topic/3
    Title is :Execute a File or Web Page Using Cron job at Cpanel Link is : http://www.webprogrammings.net/tutorial/individual_topic/2
    Title is :Cannot modify header information – headers already sent by … Link is : http://www.webprogrammings.net/tutorial/individual_topic/1

    so we can also get link, description, publishing date like this. $xml->channel->item[$i]->link , $xml->channel->item[$i]->description;

    In next topics i will describe how to make RSS FEED for Website to publish your site’s news or any update.

Leave a Reply

Your email address will not be published. Required fields are marked *