Feeds

Retrieving RSS/Atom Feeds with the Google AJAX Feed API

Using feeds to manage online news.

3 Big data security analytics techniques

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.

Top three mobile application threats

Next page: Preliminary Setup

More from The Register

next story
This time it's 'Personal': new Office 365 sub covers just two devices
Redmond also brings Office into Google's back yard
Batten down the hatches, Ubuntu 14.04 LTS due in TWO DAYS
Admins dab straining server brows in advance of Trusty Tahr's long-term support landing
Inside the Hekaton: SQL Server 2014's database engine deconstructed
Nadella's database sqares the circle of cheap memory vs speed
Microsoft lobs pre-release Windows Phone 8.1 at devs who dare
App makers can load it before anyone else, but if they do they're stuck with it
Oh no, Joe: WinPhone users already griping over 8.1 mega-update
Hang on. Which bit of Developer Preview don't you understand?
Half of Twitter's 'active users' are SILENT STALKERS
Nearly 50% have NEVER tweeted a word
Internet-of-stuff startup dumps NoSQL for ... SQL?
NoSQL taste great at first but lacks proper nutrients, says startup cloud whiz
Windows 8.1, which you probably haven't upgraded to yet, ALREADY OBSOLETE
Pre-Update versions of new Windows version will no longer support patches
IRS boss on XP migration: 'Classic fix the airplane while you're flying it attempt'
Plus: Condoleezza Rice at Dropbox 'maybe she can find ... weapons of mass destruction'
prev story

Whitepapers

Top three mobile application threats
Learn about three of the top mobile application security threats facing businesses today and recommendations on how to mitigate the risk.
Combat fraud and increase customer satisfaction
Based on their experience using HP ArcSight Enterprise Security Manager for IT security operations, Finansbank moved to HP ArcSight ESM for fraud management.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Five 3D headsets to be won!
We were so impressed by the Durovis Dive headset we’ve asked the company to give some away to Reg readers.
SANS - Survey on application security programs
In this whitepaper learn about the state of application security programs and practices of 488 surveyed respondents, and discover how mature and effective these programs are.