How to consume an Atom feed using Argotic Framework. (Part 2)

Argotic Framework provides several classes which are great for the manipulation of a feed resource. AtomFeed class could helps us retrive all the required bits about particular Atom based feed resource and latest content it holds, once the feed is loaded. Below is sample program which demonstrates a AtomFeed Object in action.

            /// Loads the feed.           
            /// <param name="urlToLoad">The URL to load.</param>
            AtomFeed feed = AtomFeed.Create(new Uri(urlToLoad));

            // get the url for Feed(same as used for load).  
            string feedUrl;
            if (feed.BaseUri != null)
            {
                feedUrl = feed.BaseUri.AbsolutePath;
            }

            // get the Title for the feed
            string feedTitle;
            if (feed.Title != null)
            {
                feedTitle = feed.Title.Content;
            }

            // get the description for the feed
            string feedDescription;
            if (feed.Subtitle != null && !feed.Subtitle.Equals(""))
            {
                feedDescription = feed.Subtitle.Content;
            }

            // get the icon for the source of the feed
            string feedIconUrl;
            if (feed.Icon != null)
            {
                feedIconUrl = feed.Icon.Uri.AbsoluteUri;
            }

            // get the format isn which feed id published
            string feedFormat;
            if (!feed.Format.Equals(""))
            {
                feedFormat = feed.Format.ToString();
            }

            // get the logog used by the publisher
            string feedLogo;
            if (feed.Logo != null)
            {
                feedLogo = feed.Logo.Uri.AbsoluteUri;
            }

            // get the rights as announced by the publisher of the feed
            string feedRights;
            if (feed.Rights != null)
            {
                feedRights = feed.Rights.Content;
            }

            // get the version of the Feed like 1.0 / 2.0 / 3.0 
            string FeedVersion;
            if (feed.Version != null)
            {
                FeedVersion = feed.Version.ToString();
            }

            // get the categories under which feed was published
            Collection<AtomCategory> categoryList;
            if (feed.Categories.Count > 0)
            {
                categoryList = feed.Categories; ;
            }

            // get the list of entries(posts / articles / whatever) from
            // this source
            if (feed.Entries != null)
            {
                List<AtomEntry> entries = feed.Entries.ToList<AtomEntry>();
            }
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