Join us on Facebook

Please wait..10 Seconds Cancel

9.28.2013

// // Leave a Comment

Want To Display Other RSS Feeds on Your Website Or Blog



What is RSS?

            
            

RSS (Rich Site Summary); originally RDF Site Summary; often dubbed Really Simple Syndication, uses a family of standard web feed formats to publish frequently updated information: blog entries, news headlines, audio, video. An RSS document (called "feed", "web feed" or "channel") includes full or summarized text, and metadata, like publishing date and author's name.




        RSS feeds enable publishers to syndicate data automatically. A standard XML file format ensures compatibility with many different machines/programs. RSS feeds also benefit users who want to receive timely updates from favorite websites or to aggregate data from many sites.

Once users subscribe to a website RSS removes the need for them to manually check it. Instead, their browser constantly monitors the site and informs the user of any updates. The browser can also be commanded to automatically download the new data for the user.

Software termed, "RSS reader", "aggregator", or "feed reader", which can be web-based, desktop-based, or mobile-device-based, present RSS feed data to users. Users subscribe to feeds either by entering a feed's URI into the reader or by clicking on the browser's feed icon. The RSS reader checks the user's feeds regularly for new information and can automatically download it, if that function is enabled. The reader also provides a user interface.

RSS Compared to Atom
Both RSS and Atom are widely supported and are compatible with all major consumer feed readers. RSS gained wider use because of early feed reader support. But, technically, Atom is more advanced and has several advantages: less restrictive licensing, IANA registered MIME type, XML namespace, URI support, Relax NG support.

The following table shows RSS elements alongside Atom elements where they are equivalent. Note: "*" indicates that an element must be provided except for Atom elements "author" and "link" which are only required under certain conditions.
 
RSS 2.0
Atom 1.0
author
author*
category
category
channel
feed
copyright
rights
description
subtitle
description*
summary and/or content
generator
generator
guid
id*
image
logo
item
entry
lastBuildDate (in channel)
updated*
link*
link*
managingEditor
author or contributor
pubDate
published (subelement of entry)
title*
title*
-




home.php 
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="getrss.js"></script>
</head>
<body>

<form>
Select an RSS-feed:
<select onchange="showRSS(this.value)">
<option value="Crazy WebDeveloper">Crazy WebDeveloper</option>
<option value="Hungry WebDeveloper">Web Developer</option>
</select>
</form>

<p><div id="rssOutput">
<b>RSS-feed will be listed here...</b></div></p>
</body>
</html>   
getrss.js
var xmlhttp;

function showRSS(str)
  {
  xmlhttp=GetXmlHttpObject();
  if (xmlhttp==null)
    {
    alert ("Your browser does not support XML HTTP Request");
    return;
    }
  var url="getrss.php";
  url=url+"?q="+str;
  url=url+"&sid="+Math.random();
  xmlhttp.onreadystatechange=stateChanged;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }

function stateChanged()
  {
  if (xmlhttp.readyState==4)
    {
    document.getElementById("rssOutput").innerHTML=xmlhttp.responseText;
    }
  }

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
} 
getrss.php
<?php
//get the q parameter from URL
$q=$_GET["q"];

//find out which feed was selected
if($q=="Hungry WebDeveloper")
  {
  $xml=("http://hungrydevelop.blogspot.com/feeds/posts/default?maxresult=5");
  }
elseif($q=="Crazy WebDeveloper")
  {
  $xml=("http://crazywebappdeveloper.blogspot.com/feeds/posts/default");
  }

$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);

//get elements from "<channel>"
$channel=$xmlDoc->getElementsByTagName('channel')->item(0);
$channel_title = $channel->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$channel_link = $channel->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$channel_desc = $channel->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;

//output elements from "<channel>"
echo("<p><a href='" . $channel_link
  . "'>" . $channel_title . "</a>");
echo("<br />");
echo($channel_desc . "</p>");

//get and output "<item>" elements
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<=2; $i++)
  {
  $item_title=$x->item($i)->getElementsByTagName('title')
  ->item(0)->childNodes->item(0)->nodeValue;
  $item_link=$x->item($i)->getElementsByTagName('link')
  ->item(0)->childNodes->item(0)->nodeValue;
  $item_desc=$x->item($i)->getElementsByTagName('description')
  ->item(0)->childNodes->item(0)->nodeValue;

  echo ("<p><a href='" . $item_link
  . "'>" . $item_title . "</a>");
  echo ("<br />");
  echo ($item_desc . "</p>");
  }
?> 

0 comments:

Post a Comment