How to get Feed from url in C#.

Below function will used to get feed item from URL.

        public static string GetRssFeedInList(string url, int howMany)
        {
            // Get the rss feed
            var x = ReturnXmlFromUrl(url);

            // Create a string builder for the feed
            var sb = new StringBuilder();

            // Try and get the movie
            var nodes = x.GetElementsByTagName("item");
            var i = 0;
            sb.Append("<ul>");
            foreach (XmlNode node in nodes)
            {
                if (i &lt;= (howMany - 1))
                {
                    sb.Append(&quot;<li>");
                    if (node != null)
                        sb.Append(String.Format("<a target='_blank' href='{0}'>{1}</a>", node["link"].InnerText,    node["title"].InnerText));
                    sb.Append("</li>");
                }
                i++;
            }
            sb.Append("</ul>");
            return sb.ToString().Trim();
        }

Page Keyword: How to Get a Feed from URL in .Net. Really Simple Syndication (RSS) feed from Url,
Get feed content from code in c#, get feed content in .net, Return rss feed item from url. Creating RSS Feed, c# Code for RSS Feed. Live Feed Item from URL. How to get Rss or ATOM feed from URL in c#, In .Net.

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