Feeds

Retrieving RSS/Atom Feeds with the Google AJAX Feed API

Using feeds to manage online news.

The Power of One Brief: Top reasons to choose HP BladeSystem

For JSON result format the <feed> element has the sub-elements described in the following table:

Sub-Element Description
title Specifies the feed title.
link Specifies the URL of the HTML version of the feed.
description Specifies the feed description.
author Specifies the feed author.
entries[] One or more entries may be present. Each entry has the following sub-elements: title-The entry title.link-URL of the HTML version of the entry.content- Specifies content of the entry including HTML tags. contentSnippet-A snippet version of the content. publishedDate-Date of publication.categories[]-One or more category String tags.

For google.feeds.Feed.MIXED_FORMAT result format, both the feed and xmlDocument sub-elements are present in the root element. An additional sub-element called xmlNode is present for each entry for MIXED_FORMAT. The xmlNode sub-element is a pointer to the XML element in the XML document in the xmlElement element.

The google.feeds.FeedControl class is used to download and display multiple feeds. The FeedControl methods are described in the following table:

Method Description
addFeed(url, label) Adds the feed specified by the url to the FeedControl.
draw(element, opt_options?) Loads the feeds and displays the feeds. The element argument specifies the DOM node that contains the resulting entries. The optional opt_options specifies the control options as a JSON object to display the results. The object has a single property called drawMode, which has the value google.feeds.FeedControl.DRAW_MODE_TABBED or google.feeds.FeedControl.DRAW_MODE_LINEAR (default).
setNumEntries(num) Specifies the number of entries for each feed. Default value is 4.
setLinkTarget(linkTarget) Specifies the link target to display the HTML for an entry. The following values may be specified:google.feeds.LINK_TARGET_BLANK google.feeds.LINK_TARGET_SELF (default)google.feeds.LINK_TARGET_TOP google.feeds.LINK_TARGET_PARENT

The Google Ajax Feed API provides a global method google.feeds.getElementsByTagNameNS(node, ns, localName), which returns a NodeList of elements of the specified local name and namespace URI.

Preliminary Setup

We want to develop a JavaScript application to download and display RSS/Atom feeds with the Google Ajax API. First, we need to register a web application URL with the Google AJAX Feed API to download and display Atom feeds.

We shall create the JavaScript application in JDeveloper. Download and install JDeveloper 10.1.3.2. To create a JDeveloper application select File>New and subsequently select General>Application in the New Gallery Click on OK. Specify an Application Name and click on OK. Specify a Project Name and click on OK. A new application and project are added to the Applications-Navigator.

Add a HTML page to the JDeveloper project by selecting the project node and selecting File>New and subsequently selecting Web Tier>HTML>HTML Page. An HTML page is added as shown in Figure 1.

Shows the JDeveloper Application.

We need to register the URL for the HTML page with the Google Ajax Feed API. Right-click on the HTML page and select Run. Obtain the URL, which is http://142.179.34.223:8990/GoogleRSS-GoogleRSS-context-root. Sign up for the Google AJAX Feed API using the URL http://code.google.com/apis/ajaxfeeds/signup.html as shown in Figure 2. Click on the Generate API Key button to generate the API key (you’ll need to be logged in to your Google user account to generate this).

Shows the generation of a Google Feed API key

Securing Web Applications Made Simple and Scalable

More from The Register

next story
Whoah! How many Google Play apps want to read your texts?
Google's app permissions far too lax – security firm survey
Chrome browser has been DRAINING PC batteries for YEARS
Google is only now fixing ancient, energy-sapping bug
Do YOU work at Microsoft? Um. Are you SURE about that?
Nokia and marketing types first to get the bullet, says report
Microsoft takes on Chromebook with low-cost Windows laptops
Redmond's chief salesman: We're taking 'hard' decisions
EU dons gloves, pokes Google's deals with Android mobe makers
El Reg cops a squint at investigatory letters
Big Blue Apple: IBM to sell iPads, iPhones to enterprises
iOS/2 gear loaded with apps for big biz ... uh oh BlackBerry
OpenWRT gets native IPv6 slurping in major refresh
Also faster init and a new packages system
prev story

Whitepapers

Top three mobile application threats
Prevent sensitive data leakage over insecure channels or stolen mobile devices.
The Essential Guide to IT Transformation
ServiceNow discusses three IT transformations that can help CIO's automate IT services to transform IT and the enterprise.
Mobile application security vulnerability report
The alarming realities regarding the sheer number of applications vulnerable to attack, and the most common and easily addressable vulnerability errors.
How modern custom applications can spur business growth
Learn how to create, deploy and manage custom applications without consuming or expanding the need for scarce, expensive IT resources.
Consolidation: the foundation for IT and business transformation
In this whitepaper learn how effective consolidation of IT and business resources can enable multiple, meaningful business benefits.