What is Rss and how can i use it in PHP for my website

Discussion in 'PHP' started by sohail.rahman, Nov 19, 2008.

  1. #1
    Hello everybody...

    I am working on a site , there is a news portion , Now I cant update news daily so I want news to come from other sites like bbc.com, Now bbc is providing RSS but how can use it.

    Plz provide me with all possible solutions

    Regards
    sohail
     
    sohail.rahman, Nov 19, 2008 IP
  2. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #2
    elias_sorensen, Nov 19, 2008 IP
  3. sohail.rahman

    sohail.rahman Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey buddy thanks
    I have the script for parsing and its working fine. I was doing this for news. Now my problem is that how can make my own rss feed??/
    some idea??
    If some body can tell me the general idea of RSS. I am learning XML, difinitly Xml cant be teached here.. so i am just asking for the flow of controll in RSS and its general idea.
    thanks and regards
    sohail
     
    sohail.rahman, Nov 26, 2008 IP
  4. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #4
    XML is just an specification to create markup languages.

    A RSS file can actually be named .xm (RSS2) l, and I think that that's the most used extension, not many uses .rss (RSS1).

    You start the file with:
    
    <?xml version="1.0"?>
    <rss version="2.0">
    
    Code (markup):
    This defines that the current file is an XML 1.0 file, more precisely: RSS 2.0.
    Then you have to make a channel, the channel contains all the news items.
    So you write <channel>.

    Now you have this:
    
    <?xml version="1.0"?>
    <rss version="2.0">
       <channel>
       </channel>
    </rss>
    
    Code (markup):
    As you can see, <rss> contains the channel, and inside <channel></channel>, you should place the news items itself.
    You can name your channel and give it a lot more parametres, like:
    
    <?xml version="1.0"?>
    <rss version="2.0">
       <channel>
           <title>My website's newsfeed</title>
           <link>http://mywebsite.com/</link>
           <description>This is the RSS for the programming news section of my website.</description>
       </channel>
    </rss>
    
    Code (markup):
    Now you have created your channel, and do only need the news items.
    Every item should be placed inside <item></item>, like this:
    
    <item>
          <title>News item 1</title>
          <link>http://mywebsite.com/news.php?id=3</link>
          <description>A quick description of the article</description>
          <pubDate>Thu, 27 Nov 2008 08:26:21 GMT</pubDate>
        </item>
    
    Code (markup):
    You should place every <item> inside the <channel> below the channel description:
    
    <?xml version="1.0"?>
    <rss version="2.0">
       <channel>
           <title>My website's newsfeed</title>
           <link>http://mywebsite.com/</link>
           <description>This is the RSS for the programming news section of my website.</description>             
              <item>
                        <title>News item 1</title>
                        <link>http://mywebsite.com/news.php?id=3</link>
                        <description>A quick description of the article</description>
                        <pubDate>Thu, 27 Nov 2008 08:26:21 GMT</pubDate>
              </item>
              <item>
                        <title>News item 2</title>
                        <link>http://mywebsite.com/news.php?id=4</link>
                        <description>A quick description of the article</description>
                        <pubDate>Thu, 27 Nov 2008 08:26:21 GMT</pubDate>
              </item>
              <item>
                        <title>News item 3</title>
                        <link>http://mywebsite.com/news.php?id=5</link>
                        <description>A quick description of the article</description>
                        <pubDate>Thu, 27 Nov 2008 08:26:21 GMT</pubDate>
              </item>
       </channel>
    </rss>
    
    Code (markup):
    That's it. Voila... You have just created your first rss feed.
     
    elias_sorensen, Nov 26, 2008 IP