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.

Friday, 5 October 2012

how to debug sharepoint feature activation

While Activating feature, we want to debug feature to go through the activation process so that we can check the issue at development server without checking the log file.
After googling I found the way to debug feature. It is as follows:


Steps

To debug a feature receiver in Visual Studio 2010
  1. Open the Visual Studio 2010 project that contains your feature.
  2. In Solution Explorer, right-click the project node, and then click Properties.
  3. On the SharePoint tab, in the Active Deployment Configuration drop-down list, click No Activation.
  4. Open the feature receiver class that you want to debug, and then insert a breakpoint.
  5. Press F5 to deploy and debug your solution. In the Attach Security Warning dialog box, click OK.
  6. Activate your feature through the browser user interface.
  7. Verify that the debugger stops at your breakpoint.
And Done.

You can find MSDN article from where I obtained this process Here