How to Generate an Rss Feed using System.ServiceModel.Syndication Framework. Part 3

Syndication-Feed provides all the properties we will need to generate a feed for our web site. This article assumes that you have a Data Access layer, which could provide the objects / content and other information needed to publish a feed. I will be using sample variables and objects, which you can replace with originals content / objects

           // Create a raw SyndicationFeed object
            SyndicationFeed feed = new SyndicationFeed();

            // Set the title for the Feed
            feed.Title = new TextSyndicationContent("codingphobia.com articles");

            // set the language you Feed is published in
            feed.Language = "en-gb";

            // set the description for the Feed / Feed resource
            feed.Description = new TextSyndicationContent("Latest Content from codingphobia.com");

            // set the rights information that apply over 
            // the consumption / distribution of the  
            // Feed / content
            feed.Copyright = new TextSyndicationContent("CC");

            // Set the categories under the Feed / content is published
            feed.Categories.Add(new SyndicationCategory("RssFeed"));
            feed.Categories.Add(new SyndicationCategory("cSharp"));
            feed.Categories.Add(new SyndicationCategory("SyndicationFeed"));

            // Set the information about the feed Generator Engine
            feed.Generator = "WordPress3.0";

            // Add the List of Post / Articles / content links 
            // and information to the Feed Object
            List<SyndicationItem> feedItems = new List<SyndicationItem>();

           
            SyndicationItem feedItem1 =
                new SyndicationItem(
                    "Really simple syndication -RSS with .Net. (Intro)",
                    "Rss Feed Fameworks",
                    new Uri("http://codingphobia.com/category/c/page/2/"));
            feedItems.Add(feedItem1);

            SyndicationItem feedItem2 =
                new SyndicationItem(
                    "How to consume an Rss feed using System."+
                    "ServiceModel.Syndication Framework. (Part 1)",
                    "Consume Rss Feed",
                    new Uri("http://codingphobia.com/2009/07/06/how-to-consume-an"+
                    "-rss-feed-using-system-servicemodel-syndication-framework-part-2/"));
            feedItems.Add(feedItem2);

            SyndicationItem feedItem3 =
                new SyndicationItem(
                    "How to consume an Atom feed using Argotic Framework. (Part 2)",
                    "Consume Atom Feed",
                    new Uri("http://codingphobia.com/2009/07/09/how-to-consume-an-atom"+
                    "-feed-using-argotic-framework-part-2/"));
            feedItems.Add(feedItem3);

            // Set the url forthe image / logo for your Feed
            // Displayed on the side of the feed page
            feed.ImageUrl = new Uri("http://codingphobia.com/imageUrl");
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s