A A A Font Size

helloitsliam

Retrieve XML from List and View and use as RSS

In one of my last posts I looked at created a HttpHandler that would use query string parameters to retrieve the Xml of a list in SharePoint. The basis for this was to replace the use of the "owssvr.dll" method due to its security requirements. In this post we will enhance it slightly and turn the Xml into an RSS feed.

For this one we will use the same base as the last one but add some extra methods for generating the RSS feed. So to begin with let's create a new file, I have called mine "GetListRSS.ashx". I then opened it up in Visual Studio 2008. Firstly we need to add the following declarations.

Then we need to add the following using statements and then declare our class as type "IHttpHandler".

Now we can start adding the code to create the XML and generate the RSS. Firstly we need to setup the query strings as before that we want to use to get the site, list and view ID's.

So for the RSS generation I can't take the credit as this is using some of the work that Sahil did on his RSS code which you can find here. I have taken some of the core code and re-purposed it to match what I needed. All in all it is using the same except for a few tweaks. The modified code is below:

As you can see it does exactly what is says it will do (thanks Sahil). Now to test it I copied this to the _vti_bin directory on my server and tested with the following URL.

http://www.helloitsliam.com/_vti_bin/GetListRSS.ashx?SiteUrl=http://www.helloitsliam.com&ListID={A462AB0D-84CF-4918-9950-D562530A5377}&ViewID={f7c353e2-e2fa-494c-a2a9-7c6dbb3bddd6}

The ending result is the following:

As you can see with a little code inside a HttpHandler you can create a component that will not only output raw Xml but also RSS. Big thanks to Sahil for the main RSS code.

This sample could be modified to include a flag that would allow you to re-purpose the results as raw XML or as an RSS feed. Using SharePoint data in its raw XML is the easiest and best approach well I think to using it inside your custom components.

You must sign in to rate content.
(Unrated)

Comments

There are no comments yet for this post.

Leave a Comment

You must be logged in to post a comment.
Superstar
Liam Cleary
Senior Solution Architect | SharePoint MVP
SUSQTECH
Sheffield, UK
Liam is working as usual, SharePoint, SharePoint and then some more SharePoint!!

Search This Blog

 

© 2010 SusQtech. All rights reserved.
Powered by SharePoint Server 2007 and using the MemberToMember SharePoint Add-On for social media capabilities.