Andrey Markeev on SharePoint

Blog on SharePoint: RSS feed

October 30, 2012

The very first question I've got when I published the post about my public blog solution, was this: "But wait, and where is your RSS feed?".

Completely forgotten about, this is where it was :)

RSS feed in SharePoint is an OOTB feature. And since my blog is implemented as a document library, probably I could just publish link to the library feed and be done with it. But have you seen this feed?

Ugly and includes some unnecessary and non-customizable stuff. Not really what I can accept for my blog. I don't want my blog to merely work, you see, I want to it to work great.

So, I started to think about possible ways to provide a custom RSS feed. One idea was to use CQWP and use its RSS feed, another was to build RSS feed from scratch via DataFormWebPart. I wasn't sure that the second way was even possible, so I asked my friend (called Google) about it, and he pointed me to Raymond Mitchel's blog post, which explained exactly this: How to build custom RSS feed with Data Form Web Part.

In brief, it turns out you can just change output type of XSLT stylesheet to XML and generate appropriate RSS XML. It took half an hour for me to do this and to test the ready solution. This is my final code:

<xsl:stylesheet xmlns:x="" 
    exclude-result-prefixes="xsl msxsl ddwrt" 

  <xsl:output method="xml" indent="yes"/>

  <xsl:decimal-format NaN=""/>

  <xsl:template match="/">

    <rss version="2.0">

        <title>Andrey Markeev on SharePoint</title>
        <description>RSS feed for Andrey Markeev blog posts.</description>
        <generator>Custom RSS via Data Form Web Part</generator>
          <xsl:value-of select="ddwrt:FormatDateTime(string(//Rows/Row[1]/@PublishedDate), 1033, 'dddd, MMMM dd, yyyy HH:mm:ss')" />

        <xsl:for-each select="/dsQueryResponse/Rows/Row">
              <xsl:value-of select="@Title" />
    <xsl:value-of select="@FileRef" />
              <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
              <xsl:value-of select="@Preview" disable-output-escaping="yes" />
              <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
            <author>Andrey Markeev</author>
              <xsl:value-of select="ddwrt:FormatDateTime(string(@PublishDate), 1033, 'dddd, MMMM dd, yyyy HH:mm:ss')"/>
            <guid isPermaLink="true">
    <xsl:value-of select="@FileRef" />




Note: all dates should be converted to RSS format.

Also, there is one small inconvenience: even if you remove all the content except DataFormWebPart itself from the page, SharePoint designer automatically generates head tag each time you save your page, as follows:

<meta name="WebPartPageExpansion" content="full" />
<meta name="ProgId" content="SharePoint.WebPartPage.Document" />

To workaround this, I had to place this tag inside server-side Panel with Visible set to false:

<asp:Panel runat="server" Visible="false">
<meta name="WebPartPageExpansion" content="full" />
<meta name="ProgId" content="SharePoint.WebPartPage.Document">

Also, I had to move the whole fragment and place it to the bottom of the page, after DFWP.

Finally, I've got the desired result:


DataFormWebPart is a stunningly powerful webpart. And it turns out, that you can use it not only for displaying data from lists or other data sources on a web page, but also for presenting such data in some XML format (not obligatory RSS).

This opens many opportunities for XML-based integration with external systems.

Like it?

Posts of this series

  1. Public blog on SharePoint
  2. Blog on SharePoint: Series
  3. Blog on SharePoint: RSS feed (this post)

About me

I'm SharePoint MVP, published author, frequent speaker, opensource projects creator and online expert.

I'm one of the top 10 experts on SharePoint StackExchange:

profile for omlin at SharePoint, Q&A for SharePoint enthusiasts

You can learn more about me on LinkedIn and Facebook.

Want to follow?

Subscribe to RSS!


Blog archive