Friday 14 October 2011

Sharepoint 2010 How to Read Rss Object Model

A Tip on how to read Rss feed that you get from SharePoint List\Libraries using the Objetc model.

protected string GetRSSFeed(string ListRssUrl)
{

string rss_text = "";
string ItemTitle = "";
string Url = "";
string description = "";

XPathDocument doc = new XPathDocument(ListRssUrl);
XPathNavigator nav = doc.CreateNavigator();
XPathNodeIterator items = nav.Select("//item");

while (items.MoveNext())
{
XPathNavigator navCurrent = items.Current;

ItemTitle = navCurrent.SelectSingleNode("title").InnerXml;
Url = navCurrent.SelectSingleNode("link").InnerXml;
description = navCurrent.SelectSingleNode("description").InnerXml;
}
}

No comments:

Post a Comment