The RSS Toolkit also adds support for creating a
strongly-typed object model over a remote RSS feed. This allows you to program
against RSS data in a clean, easy way. You can do this one of two ways:
1) Using the rsssdl.exe utility that ships with the
toolkit. This is a command-line tool that generates a strongly-typed class library
based on a provided RSS URL feed (sort of like wsdl.exe does for
web-services). For example, I could use it against my ScottGu RSS blog feed
like so to generate a Scottgu.cs file containing C# classes that provide a
strongly-typed object model around it:
Figure 7
I could then add the generated “scottgu.cs” file to my
project and instantiate and use the class framework to programmatically
databind the RSS channel’s items against a GridView (note that each of the
Items is strongly typed as a "ScottGuChannelItem" -- and has a
strongly-typed object model based on the schema of the RSS feed):
Listing 2
ScottGuChannel channel =ScottGuChannel.LoadChannel();
GridView1.DataSource = channel.Items;
GridView1.DataBind();
or alternatively:
2) The RSS toolkit also ships with a new ASP.NET 2.0
build-provider that allows you to declaratively add .rssdl file definitions in
your app_code directory. For example like so:
Listing 3
<rssdl>
<rss name="ScottGu"url="http://weblogs.asp.net/scottgu/rss.aspx" />
</rssdl>
This will then automatically generate and build a RSS
channel proxy into your project for you to use (no command line tool usage
required).