Try Xenarius Free

RSS Reader Demo

The RSS Reader demo illustrates how to work use non-standard REST web services and process XML data. This is a basic application for browsing and reading RSS feeds. This article describes the main aspects of creating this app, such as binding to a data service and processing XML.

This demo consists of the following six views:

  • News Feed – displays the current user feed. It aggregates data from the selected RSS feeds and displays this data to a user;

  • Another version of the News Feed view, displayed when the feed is empty;

  • Entry Content – displays the feed entry;

  • Add New Feed – enables a user to enter RSS feed URL and lists the suggested feeds;

  • Your Feeds List – lists the feeds to which a user is subscribed;

  • About RSS Reader – displays information about the demo.

Retrieving Data

The current feed is retrieved by the currentFeed method defined in the Application Options (from the Global Functions section). The subscribed feeds are stored in the savedFeeds data provider.

The currentFeed function retrieves these feeds and iterates over them. RSS feeds return data in XML format. This function uses the **Get data **operation to retrieve a proper object from the XML data returned by the server.

View Design

The News Feed view contains the OnShow event handler that checks whether or not the savedFeeds data provider has any feeds. Xenarius fires the event on opening the view. If the feed is empty, the program redirects to a special version of the News Feed view, for which a similar OnShow handler is provided, redirecting a user back if any subscriptions were found.

The Entry Content view caption displays an expression that returns the current feed’s title.

The Your Feeds List view contains a demo list of suggested feeds. This list uses custom row templates for displaying buttons next to feed titles. This view also displays a local load indicator on retrieving data from the server. This indicator is bound to the $model.loading model property. The Add Feed button changes its value and the load indicator automatically reacts to this change.