Something a little less SharePoint. If you wanted to consume an RSS feed (such as my homepage) and your using .NET framework 3.5+, then you could use the following code:
XDocument rssFeed = XDocument.Load(@"http://httpcode.com/blogs/SyndicationService.asmx/GetRss"); var posts = from item in rssFeed.Descendants("item") select new { Title = item.Element("title").Value, Published = DateTime.Parse(item.Element("pubDate").Value), Url = item.Element("link").Value, }; //BlogPosts is a ListView BlogPosts.DataSource = posts; BlogPosts.DataBind();
How about taking my last 5 twitter posts, but lets remove my name:
XDocument twitterFeed = XDocument.Load(@"http://twitter.com/statuses/user_timeline/14554389.rss"); var titterPosts = from item in twitterFeed.Descendants("item") select new { Title = item.Element("title").Value.Replace("DanielPollard:","") }; //TwitterPosts is a ListView - Notice the Take(5) below TwitterPosts.DataSource = titterPosts.Take(5); TwitterPosts.DataBind();
There's a lot to love about Linq.