If you find this article useful, consider making a small donation to show your support for this web site and its content.
DiscountASP
AboutMe
About me:
Hi. My name is Farooq Kaiser and I'm a software developer from Toronto, Canada.

XML LINQ for RSS Feed

by Farooq Kaiser 5. February 2009 04:33
Using LINQ we can easily consume RSS feed into our project. 
 
Include the following namespaces in the project.
 
using System.Xml.Linq;
using System.Linq; 

 
    protected void Page_Load(object sender, EventArgs e)
    {
            string strFeed = "http://weblogs.asp.net/aspnet-team/rss.aspx";
            StringBuilder sb = new StringBuilder(); 
            var feed = XDocument.Load(strFeed);
            var items = feed.Root.Element("channel").Elements("item");
            foreach (var item in items)
                sb.Append(item);

            Panel1.Controls.Add(new LiteralControl(sb.ToString()));    

    }

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

.NET | asp.net | C# | XML

Jobs Autos Real estate Videos Power by Google
awesome comments