Feeds

Retrieving RSS/Atom Feeds with the Google AJAX Feed API

Using feeds to manage online news.

Security and trust: The backbone of doing business over the internet

Keeping up to date with updates to different news websites can be a major burden – which can be ameliorated with an RSS feed. With an RSS feed, the updates are pushed to you as they become available.

RSS is a collection of web feed formats, specified in XML and used to provide frequently updated digital content to users. The first version of RSS, RSS 0.9, was created by Netscape in 1999 but the “RSS” acronym has different interpretations for different subsequent standards: for RSS 2.0, Really Simple Syndication; for RSS 0.91 and RSS 1.0, Rich Site Summary; for RSS 0.9 and RSS 1.0, RDF Site Summary.

An RSS feed may be read using a feed reader such as Google Reader or RssReader. It may also be read using a Feed API and Google provides the Google AJAX Feed API to receive any RSS feed.

An RSS Feed may be displayed in JSON Result Format, XML Result Format, or combined JSON/XML Result Format. JSON (JavaScript Object Notation) is a data interchange format used to transmit structured data and is based on the following data structures:

  1. Object-Collection of key-value pairs, separated by a comma, and enclosed in { }.
  2. Array-Ordered sequence of values, separated by a comma and enclosed in [ ].

By default, the Ajax Feed API returns the feed in JSON format.

Because of the incompatibilities between the various versions of RSS and the limitations of RSS, a new syndication specification, Atom, was introduced in 2003. Atom is not a strict superset of RSS - for a comparison between RSS 2.0 and Atom 1.0 see here. An Atom feed has 3 main advantages over the original RSS feed:

  • An RSS feed supports only plain text and HTML, whereas an Atom feed supports various additional content types such as XHTML, XML and binary, and references to video and audio content.
  • Atom is being standardised by the IETF (RFC4287), whereas RSS is not standardised.
  • Atom supports XML standard features such as XML Schema. RSS doesn’t.

We shall use standard Atom feeds in this article. It’s also worth noting that Microsoft has introduced the Simple Sharing Extensions (SSE), which “extend” the Atom 1.0 and RSS 2.0 specifications to provide item sharing between cross-subscribed feeds. However, note that an extended standard is no longer really a standard, although this one appears to be using, rather than re-inventing, the underlying RSS/Atom specs.

Overview of Google Ajax Feed API

The Google Ajax Feed API generates a result document, whose structure is different from either an RSS 2.0 or the Atom 1.0 feed. For example, it may contain elements such as "contentSnippet" and "publishedDate". Neither Atom 1.0 nor RSS 2.0 has these elements. The "contentSnippet" element corresponds to the snippet version of the <content> or <summary> element in Atom 1.0 and <description> element in RSS 2.0. The "publishedDate" element corresponds to the <published> element in Atom and the <pubDate> element in RSS 2.0. The Google Feed API uses its own set of result elements to generate a uniform result format for an Atom 1.0 feed and an RSS 2.0 feed, which each have some elements different. A Google Ajax Feed is represented by the google.feeds.Feed class.

The Feed class methods do not have a return type. The Feed class methods are presented in the following table:

Method Description
load(callbackFunction) Downloads the feed from the Google server. The callbackFunction is invoked when the download is complete. The callbackFunction is invoked with a argument that represents the result of the feed.
setNumEntries(num) Sets the number of feed entries. Default value is 4.
setResultFormat(format) Sets the result format. One of the following values may be specified: google.feeds.Feed.JSON_FORMAT (the default), google.feeds.Feed.XML_FORMAT, or google.feeds.Feed.MIXED_FORMAT.

The root element of the feed result is <root>. If the loading generates an error the root element has an <error> sub-element. The <error> element has sub-elements <code> and <message>. The <code> element specifies the error code and the <message> element specifies the description of the error.

If the result format is JSON_FORMAT or MIXED_FORMAT the <root> element has a sub-element called <feed>. If the result format is XML_FORMAT or MIXED_FORMAT the root element has an element called <xmlDocument> . The xmlDocument element contains the XML document for the feed.

Providing a secure and efficient Helpdesk

Next page: Preliminary Setup

More from The Register

next story
New 'Cosmos' browser surfs the net by TXT alone
No data plan? No WiFi? No worries ... except sluggish download speed
'Windows 9' LEAK: Microsoft's playing catchup with Linux
Multiple desktops and live tiles in restored Start button star in new vids
iOS 8 release: WebGL now runs everywhere. Hurrah for 3D graphics!
HTML 5's pretty neat ... when your browser supports it
'People have forgotten just how late the first iPhone arrived ...'
Plus: 'Google's IDEALISM is an injudicious justification for inappropriate biz practices'
Mathematica hits the Web
Wolfram embraces the cloud, promies private cloud cut of its number-cruncher
Mozilla shutters Labs, tells nobody it's been dead for five months
Staffer's blog reveals all as projects languish on GitHub
SUSE Linux owner Attachmate gobbled by Micro Focus for $2.3bn
Merger will lead to mainframe and COBOL powerhouse
iOS 8 Healthkit gets a bug SO Apple KILLS it. That's real healthcare!
Not fit for purpose on day of launch, says Cupertino
prev story

Whitepapers

Secure remote control for conventional and virtual desktops
Balancing user privacy and privileged access, in accordance with compliance frameworks and legislation. Evaluating any potential remote control choice.
WIN a very cool portable ZX Spectrum
Win a one-off portable Spectrum built by legendary hardware hacker Ben Heck
Storage capacity and performance optimization at Mizuno USA
Mizuno USA turn to Tegile storage technology to solve both their SAN and backup issues.
High Performance for All
While HPC is not new, it has traditionally been seen as a specialist area – is it now geared up to meet more mainstream requirements?
The next step in data security
With recent increased privacy concerns and computers becoming more powerful, the chance of hackers being able to crack smaller-sized RSA keys increases.