Winsmarts.com

Microsoft MVP

MVP Logo

Awarded the Microsoft MVP Award.

Hosted By

blah!bLaH!BLOG!!

SPRSS: Using CleanRSS.aspx

Posted on 3/30/2008 @ 5:31 PM in #Sharepoint | 11 comments | 2901 views

What is this blogpost about?

It is about a central peice of SPRSS, which is a community project that provides enhanced RSS functionality in SharePoint. More details on SPRSS.
This blogpost presents a short 5 min tutorial on how you can use CleanRSS.aspx.

What does CleanRSS.aspx do?

It does your dishes. Not quite. It pumps out clean manageable RSS out of any SharePoint list. As an example, consider the announcements list.  Below is an image of the out of the box RSS produced:



Now, as a comparison, here is the RSS produced by CleanRSS.aspx --



Note any difference? Well, there are 2 differences -

a) CleanRSS.aspx actually splits out each column as it's own XML element. This minor difference is incredibly valuable, because now you can attach any XSLT stylesheet, and render the above announcements in any way/shape or form you want.

b) See that IsEditable? That is True if the logged in user can edit that particular list item. This lets you create Editable UI .... RIGHT on the rendering surface. w00t!

How do you use CleanRSS.aspx?

The tenet I followed was, keep it damn easy to cook up a URL using CleanRSS.aspx. There are 2 ways to use CleanRSS.aspx:

a) Leverage a View on a list:

   Here are the steps:

  1. On ANY list, ANY view, click on Modify View, and choose the appropriate columns/sort order/filter/whatever you want!! You must include the "Title (linked to edit item)" column.
  2. Then on that list, copy paste the RSS URL as shown below:



  3. Now, change the URL from --

    http://moss2007/_layouts/listfeed.aspx?List=51511bf8%2Da6ae%2D4a51%2Dbeb4%2Dc23f30309633&View=5edce7de%2D1dd1%2D42e0%2Da786%2Def1e5cf2f4ff

    .. to ..

    http://moss2007/_layouts/SPRSS/CleanRSS.aspx?List=51511bf8%2Da6ae%2D4a51%2Dbeb4%2Dc23f30309633&View=5edce7de%2D1dd1%2D42e0%2Da786%2Def1e5cf2f4ff

    The change is shown in red bold.

    Thats it .. test in a browser. This should produce Valid RSS.
  4. Note: Omitting a View .. will make CleanRSS.aspx target the default view.

b) Leverage a list item:

Sometimes, you will want to have 1 list, with a number of common peices of text .. a.k.a. ReusableText functionality in a publishing site .. only this time, across sites and even farms. In order to do so, you can extract RSS with a single item.. without having to create a View for it. How do you do it? Easy.

  1. As before, create a URL that looks like this -

    http://moss2007/_layouts/SPRSS/CleanRSS.aspx?List=51511bf8%2Da6ae%2D4a51%2Dbeb4%2Dc23f30309633
  2. Now, add an additional Query string .. as shown below:
  3. http://moss2007/_layouts/SPRSS/CleanRSS.aspx?List=51511bf8%2Da6ae%2D4a51%2Dbeb4%2Dc23f30309633&Title=Some Random Announcement

  4. Thats it :). Test in a browser, to make sure it works.

On 4/16/2008 12:43:14 PM Rand Williams said ..
This is sweet.

On 6/24/2008 5:17:31 AM Ulrich Bernskov said ..
This is just what I was looking for.
However. I have a problem with the intended use:
If I view the feed with /SPRSS/CleanRSS.aspx using several different RSSviewers and all looks well.
I want to use the XML viewer webpart. And just as you depicted the OOTB feed does not treat additional cloums added to "Annoucements" or other lists as proper elements, but it does render the feed. (Providing the needed ajustment to the security has been set for the list - Either anonymous Read or Kerberous/Worker process) Now when I try the use the /SPRSS/CleanRSS.aspx in the XML webpart I get the error
"Cannot retrieve the URL specified in the XML Link property. For more assistance, contact your site administrator."
If I feed the same URL into the RSS Webpart I get the "The RSS webpart does not support authenticated feeds." which should indicate that rights were incorrectly set.
But if I use the /listfeed.aspx it renders in XML and RSS WebPart. Any hints?

On 6/24/2008 5:19:30 AM Ulrich Bernskov said ..
I also tried to use the SPRSS.webpart I found in the Codeplex wsp archive.
When I use that I get this:
<snip>
Feed not available at this time! Error message:
System.Net.WebException: The remote server returned an error: (401) Unauthorized.
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadData(Uri address)
at SPRSS.WebParts.RSSRender.Render(HtmlTextWriter writer)
NTSERVER\SPAdmin
RSS Url: http://tst2/Editors/EditDemo/_layouts//SPRSS/CleanRSS.aspx?List=451bf463%2D8f2c%2D4932%2D9ffe%2Dc08e3c346cac&View=3d711c04%2D3d09%2D486f%2D82c1%2D51512500402a
</snip>

On 6/24/2008 8:15:33 AM Sahil Malik said ..
The second error is regarding the webpart not being able to access the feed. Is the URL ok? Is network connectivity ok? Are you using FBA?

On 6/24/2008 8:33:37 AM Ulrich Bernskov said ..
Unfortunatly I cannot post screenshots, but yes I am very sure the URL is formatted correctly.
When I use the OOTB RSS link with /listfeed.aspx then I get the result rendered in any RSS reader, but have the limitations of coloumsn not being treated as <elements>
When I enter /SPRSS/CleanRSS.aspx it works when I press the "Test link" and see the result in IE, but the feed does not work in either XML nor RSS viewer webpart.
Not even the SPRSS.webpart will render and spews the above error.

On 6/24/2008 8:34:01 AM Ulrich Bernskov said ..
I do not know what FBA refers to?

On 6/24/2008 10:07:13 AM Ulrich Bernskov said ..
if FBA is From Based Authentication then no. I use Kerberos and have given anonymous read access to lists and read access to this specific lsit. As stated before. The OOTB /listfeed.aspx feed renders /SPRSS/CleanRSS.aspx does not. It appears that the /SPRSS versions gives med this:
<item><title>test2</title><link>Lists/Announcements/DispForm.aspx?ID=12</link><description><Attachments>True</Attachments><Modified>24/06/2008 16:37</Modified><IsEditable>False</IsEditable></description></item> whereas the original /listfeed.aspx gives me this:
<item><title>test2</title><link>http://tst2/Editors/EditDemo/Lists/Announcements/DispForm.aspx?ID=12</link><description><div><b>Body:</b>; <div class=ExternalClassE1DE47F7B24D4FCA985B9C8159C71F7E>
<div>
<div>
<p><font size=2>Quisque vitae justo eu velit feugiat tincidunt. Proin non risus. Nunc porta. Sed est dui, cursus at, egestas a, semper non, sapien. Pellentesque pede nisi, dapibus ut,...</div>
<div><b>Attachments:</b> <a href="http://tst2/Editors/EditDemo/Lists/Announcements/Attachments/12/5s2work.jpg">http://tst2/Editors/EditDemo/Lists/Announcements/Attachments/12/5s2work.jpg</a><br><a href=""></a></div>
</description><author>Ulrich Bernskov</author><pubDate>Mon, 23 Jun 2008 08:02:49 GMT</pubDate><guid isPermaLink="true">http://tst2/Editors/EditDemo/Lists/Announcements/DispForm.aspx?ID=12</guid></item>;

On 6/24/2008 1:05:42 PM Ulrich Bernskov said ..
If I add the code from http://blah.winsmarts.com/2007-10-CQWP_Frustrations_-_Introducing_CARBURETUR.aspx
to the XML web part in XML Editor and add the /SPRSS/CleanRSS.aspx feed and do not use any XSL I get the following result: using System; using System.Runtime.InteropServices; using System.Web.UI; using System.Web.UI.WebControls.WebParts; using System.Xml; using System.Xml.Serialization; using Microsoft.SharePoint; using Microsoft.SharePoint.WebControls; using Microsoft.SharePoint.WebPartPages; using System.Xml.Xsl; using System.IO; using System.Reflection; using System.Xml.XPath; namespace RSSRender { [Guid("ab18a8de-2765-4c1e-b99a-82f93a27f667")] public class RSSRender : System.Web.UI.WebControls.WebParts.WebPart { private string rssUrl; private string xslTransform; [WebBrowsable(true)] [Personalizable(true)] public string XSLTransform { get { return xslTransform; } set { xslTransform = value; } } [WebBrowsable(true)] [Personalizable(true)] public string RssUrl { get { return rssUrl; } set { rssUrl = value; } } public RSSRender() { this.ExportMode = WebPartExportMode.All; TextReader ootbXSLTStream = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("RSSRender.OOTBXSLT.xml")); xslTransform = ootbXSLTStream.ReadToEnd(); } protected override void Render(HtmlTextWriter writer) { XmlDocument rssDoc = new XmlDocument(); try { System.Net.WebClient wc = new System.Net.WebClient(); wc.Credentials = System.Net.CredentialCache.DefaultCredentials; byte[] rssBytes = wc.DownloadData(rssUrl); string rssText = System.Text.ASCIIEncoding.ASCII.GetString(rssBytes, 3, rssBytes.Length - 3); rssDoc.LoadXml(rssText); } catch (Exception ex) { writer.Write("Feed not available at this time! Error message:
" + ex.ToString() + "
"); writer.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name); } XmlDocument xsltDoc = new XmlDocument(); xsltDoc.LoadXml(xslTransform); writer.Write(Transform(rssDoc, xsltDoc)); } private static string Transform(IXPathNavigable input, IXPathNavigable xslt) { XslCompiledTransform xsltProcessor = new XslCompiledTransform(); xsltProcessor.Load(xslt); Stream results = new MemoryStream(); if (input is XmlDocument) { xsltProcessor.Transform(input, null, results); } results.Position = 0; StreamReader rdr = new StreamReader(results); return rdr.ReadToEnd(); } } } If I add any XSL I get this: Failed to apply XSLT to the content.
Frustrating.

On 6/24/2008 1:26:29 PM Sahil Malik said ..
Ulrich - unfortunately, this is just something I'd have to look more closely :(

On 6/24/2008 3:34:10 PM Ulrich Bernskov said ..
Appreciated. The ability to feed any coloum as <element> is high on my list :-)

On 9/14/2008 11:43:40 AM Ulrich Bernskov said ..
Any progress?

Please post your comments:


Your feedback will be submitted for moderation, and will appear after it is approved.

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 

Site designed and maintained by Sahil Malik | All Rights Reserved. ©2007 WinSmarts.com.