Feeds

Retrieving RSS/Atom Feeds with the Google AJAX Feed API

Using feeds to manage online news.

7 Elements of Radically Simple OS Migration

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.

Endpoint data privacy in the cloud is easier than you think

Next page: Preliminary Setup

More from The Register

next story
PEAK LANDFILL: Why tablet gloom is good news for Windows users
Sinofsky's hybrid strategy looks dafter than ever
Leaked Windows Phone 8.1 Update specs tease details of Nokia's next mobes
New screen sizes, dual SIMs, voice over LTE, and more
Fiendishly complex password app extension ships for iOS 8
Just slip it in, won't hurt a bit, 1Password makers urge devs
Mozilla keeps its Beard, hopes anti-gay marriage troubles are now over
Plenty on new CEO's todo list – starting with Firefox's slipping grasp
Apple: We'll unleash OS X Yosemite beta on the MASSES on 24 July
Starting today, regular fanbois will be guinea pigs, it tells Reg
Another day, another Firefox: Version 31 is upon us ALREADY
Web devs, Mozilla really wants you to like this one
Secure microkernel that uses maths to be 'bug free' goes open source
Hacker-repelling, drone-protecting code will soon be yours to tweak as you see fit
Cloudy CoreOS Linux distro declares itself production-ready
Lightweight, container-happy Linux gets first Stable release
prev story

Whitepapers

7 Elements of Radically Simple OS Migration
Avoid the typical headaches of OS migration during your next project by learning about 7 elements of radically simple OS migration.
Implementing global e-invoicing with guaranteed legal certainty
Explaining the role local tax compliance plays in successful supply chain management and e-business and how leading global brands are addressing this.
Consolidation: The Foundation for IT Business Transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.
Solving today's distributed Big Data backup challenges
Enable IT efficiency and allow a firm to access and reuse corporate information for competitive advantage, ultimately changing business outcomes.
A new approach to endpoint data protection
What is the best way to ensure comprehensive visibility, management, and control of information on both company-owned and employee-owned devices?