Tuesday, 16 October 2012

Access rss feed for sharepoint list programmatically

After googling, I got the code to access rss feed for sharepoint list as follows:

protected static void GetRSS(string ListRssUrl, SPWeb oWeb)
            string rss_text = string.Empty;
            string title = string.Empty;
            string link = string.Empty;
            string description = string.Empty;
            string athr = string.Empty;
            string pub = string.Empty;
            XPathDocument doc = new XPathDocument(ListRssUrl);
            XPathNavigator nav = doc.CreateNavigator();
            XPathNodeIterator items = nav.Select("//item");
            while (items.MoveNext())
                XPathNavigator navCurrent = items.Current;
                title = navCurrent.SelectSingleNode("title").InnerXml;
                link = navCurrent.SelectSingleNode("link").InnerXml;
                description = navCurrent.SelectSingleNode("description").InnerXml;
                athr = navCurrent.SelectSingleNode("author").InnerXml;
                pub = navCurrent.SelectSingleNode("pubDate").InnerXml;

//To get rss feed url use the below code.

using (SPSite oSite = new SPSite("<Site URL>"))
                    using (SPWeb oWeb = oSite.OpenWeb())
                        SPList list = oWeb.Lists["Contributor"];
                        string ListRssUrl = oWeb.Url + "/_layouts/listfeed.aspx?list=" + list.ID;
                        GetRSS(ListRssUrl, oWeb);

For List rss feed, roy need to enable Anonymous access. There is a good Link for this
Click here to view How to enable Anonymous access.
I have get very good reference here for rss feed.


  1. I am genuinely glaԁ to rеad thіs website pοsts which carries рlenty of valuable data, thanκs for proѵіding thesе κindѕ
    of informаtion.

    Alѕο viѕit my ωeb blog - sesja fotograficzna w ciąży

  2. Hello, I want to generate RSS feed URL to update one of our sharepoint list data automatically into our mobile application, but we are using cross site publishing, so result I'm getting fine in cross site publishing but when I try to change the url with our public facing website it's not displaying anything. May I Please know the reason behind this??