O'Reilly logo

Data-Driven Services with Silverlight 2 by John Papa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Requesting a Feed

Both WebClient and HttpWebRequest can make asynchronous calls to web services, including requests for syndication feeds. WebClient is the simpler of the two class libraries as it uses HttpWebRequest under the covers. Using one of these classes to make a web request for a syndicated feed, you can retrieve the data as a string or as a stream, depending on what you desire. The examples in this chapter demonstrate techniques with both classes and both return formats.

The first step in requesting a feed is to find the feed’s URI. Many websites publish their syndication feed address in a conspicuous spot on their web page. The format of the feed may be either RSS or Atom. Because both of these protocols are commonly used, any code that requests a feed should be prepared to work with either RSS or Atom. For the following examples, the http://feeds.feedburner.com/johnpapa feed will be requested.

Note

The code solution for the following example is named SyndicationReader and you can find it in the code folder for this chapter.

The example application (shown in Figure 10-2) will request a feed from an address that the user enters. When the feed is returned, it is loaded into a SyndicationFeed object and is bound to the control, where it displays information about the feed and its individual items.

The SyndicationReader application allows the user to choose between using WebClient and HttpWebRequest. Although a real-world application targeted at nondevelopers would likely not ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required