RSS
Introduction
- You can subscribe to an RSS feed provided by a news site (e.g. the BBC) to get headlines, without having to actually visit the site
- If the headline interests you, you can then follow the link to find out more
Page 2
RSS history
- One of the main issues with RSS is that there are several versions
- The currently-used versions include 0.91, 1.0 and 2.0, and an RSS derivative known as Atom
Page 4
RSS evolution
- Initial version was 0.90, developed by Netscape and based on the RDF format; here, RSS stood for RDF Site Summary
- 0.90 evolved into 0.91, a simpler format (Rich Site Summary) which was not based on RDF
- A separate group of people evolved 0.90 into 1.0, which continued to be based on RDF
- 0.91 then evolved into 2.0 (1.0 could not be used as it had already been used for the RDF branch
- Currently, 0.91, 1.0 and 2.0 are all widely used
- This makes it hard if you want to write RSS reader software, as you have to support all three versions
- However, if you provide an RSS feed, you need only choose one
- We will be looking at 2.0 as it has the easiest-to-understand format
Page 5
References on RSS specifications and background
- Wikipedia article
- Syndicated content: it's more than just some file formats (in-depth, academic article)
- RSS History
- RSS 1.0 Specification
- RSS 2.0 Specification
Page 6
An example of RSS
<?xml version='1.0'?>
<rss version='2.0'>
<channel>
<title>The New Forest Guardian</title>
<link>http://aquarius.solent.ac.uk/students/whiteleg/webapps/rss/nfg/
</link>
<description>The New Forest Guardian - Your top local source of
info for the New Forest area </description>
<item>
<title>Open Mapping comes to the New Forest</title>
<link>http://aquarius.solent.ac.uk/students/whiteleg/webapps/
rss/nfg/nfgstory.php?id=2 </link>
<description>This weekend several volunteers from all over the
world descend on the New Forest to create a new, copyright-free
digital map.</description>
<pubDate>Fri, 22 Sep 2006 12:00:00 GMT</pubDate>
</item>
<item>
<title>Killer Pig on the Loose !!!!!;/title>
<link>http://aquarius.solent.ac.uk/students/whiteleg/webapps/
rss/nfg/nfgstory.php?id=1 </link>
<description>Man-eating pig attacks New Forest villagers
</description>
<pubDate>Fri, 22 Sep 2006 12:30:00 GMT</pubDate>
</item>
</channel>
</rss>
Page 7
Explanation of example
- A channel is an RSS feed relating to one particular topic, in this case, news items in the New Forest provided by the New Forest Guardian website
- The channel has three important tags describing it:
- title - the title of the feed
- link - the address of the feed
- description - a description of the feed
- The channel then has a number of individual items (e.g. stories)
- Each item has a:
- title - e.g. a headline
- link - URL where you can find out more
- description - a short description of the item
- pubDate - the date of publication, you can use this to select the latest items
Page 8
How is an RSS feed generated?
- Imagine you wanted to create an RSS feed of updates to your website... how would you do this?
- On a very basic level, you create the RSS XML file on your server and publish its URL
- People can then subscribe to the feed by entering the URL into news-reading software (see below)
- However this has one obvious disadvantage.. the XML would have to be manually updated each time you wanted to send out a new item!
Page 9
Auto-generation of RSS feeds
- Another possibility is to generate RSS feeds dynamically using server-side scripting, e.g. PHP
- For example, if you were running a news site, you could generate the feed by querying the database for the latest stories
- Code example:
<?php $conn=mysql_connect("localhost","username","password"); mysql_select_db("database"); $result=mysql_query("SELECT * FROM stories ORDER BY ID"); echo "<rss version='2.0'>"; echo "<channel>"; echo "<title>New Forest Guardian</title>"; echo "<link>http://newforestguardian.org.uk/rss.php</link>"; echo "<description>Latest stories from the NFG</description>"; while($row=mysql_fetch_array($result)) { echo "<item>"; echo "<title>$row[title]</title>"; echo "<link>fullstory.php?id=$row[ID]</link>"; echo "<description>$row[description]</description>"; echo "<pubDate>$row[pubDate]</pubDate>"; echo "</item>"; } echo "</channel>"; echo "</rss>"; mysql_close($conn); ?> - Note how the contents of each RSS tag are based on the database
- Also note how the link tag contains a link to the full story; we do this by linking to another script, fullstory.php, and passing it the ID of the story as a query string
Page 10
RSS and Blogs
- The newest use of RSS is in association with blogs
- Blogs (weblogs) are basically online "diaries", frequently updated by their author, and used to publish all manner of things from progress on a project to random thoughts, ideas and opinions - to which readers can respond
- To do your own blog, you install blogging software such as Wordpress on your web server
- Blogging software automatically creates RSS feeds of each blog entry
- Thus people can subscribe to your blog - and be informed of the latest entries - by subscribing to its RSS feed
Page 11
Subscribing to an RSS feed
There are a number of ways to subscribe to an RSS feed:
- Newsreader software
- Websites such as Bloglines
- Directly through your browser: Firefox has integrated RSS support
Page 12
Newsreader software
- Specialised, standalone software for reading RSS feeds
- Typically contacts the RSS feed URL at regular intervals (e.g. every hour) to get the latest items
Page 13
RSS-reading websites
- Websites which allow you to subscribe to an RSS feed
- You specify which feed(s) you want to subscribe to
- High level of control e.g. only show items less than a week old
- Examples: Bloglines
Page 14
Direct browser support
- Firefox has built in feed-reading support
- If you visit a website with an associated RSS feed, the orange RSS icon will appear in the address bar
- You can then click on the feed and it will add it to your "Live Bookmarks"
- To view a given RSS feed at any time you can then:
- Go to Bookmarks-Bookmarks Toolbar Folder
- Select the feed you're interested in
- The titles of the latest items in the feed will then appear
Page 15
Publicising your feeds
- Feeds often have fairly obscure URLs, e.g.
http://www.fredbloggs.com/TheBloggsBlog/myinterestingfeed.rss
- To indicate that a site has an appropriate RSS feed, include a link to the feed on the main page(s)
- This line of code, added to the HTML pages of the site, will also help
newsreaders pick up the feed:
<link rel='alternate' type='application/rss+xml' title='freemap rss feed' href='/webapps/rss1.rss' />
- If you then enter a website address (e.g. www.free-map.org.uk) in a newsreader, it will find the RSS feed automatically
Page 16
Integrating RSS feeds into other websites
- With a bit of scripting, it is possible to integrate a RSS feed made by someone else into your own website
- e.g. on free-map.org.uk I might want to include the blog entries at www.opengeodata.org
- There are libraries available for reading RSS, e.g. for PHP: MagpieRSS
- This would work by:
- PHP script on your website requests RSS feed from another site
- RSS sent back to your site
- PHP reads the RSS and displays links to (and perhaps descriptions of) the articles