Wednesday, January 14, 2015

SharePoint 2013: how to display an RSS feed using the XML Viewer web part

Introduction

In SharePoint 2010 and 2013, you can easily present RSS feed content using the RSS Viewer web part. You can also do this using the XML Viewer web part, with the added benefit have employing XML methods and XSLT styling control.  This posting presents a simple RSS implementation using the SharePoint XML Viewer web part.  It displays 5 items in the RSS feed.  It works with any standard RSS feed - no need to change anything presented here.  Just paste in and go.

Procedure
  1. Using IE, navigate to the target site.
  2. Open the page in Edit mode.
  3. Click on Add a Web Part in the target zone.
  4. In the ribbon, in the Categories section, select Content Rollup, and then, in the Parts section, select XML Viewer.
  5. Select the new web part by entering a check into its checkbox.
  6. On the ribbon, select the WEB PART tab, and then in the Properties group click Web Part Properties.
  7. In the XML Link box, enter the URL to the RSS feed.
  8. Click the XSL Editor... button.
  9. Enter the following XSL:
    <?xml version="1.0" encoding="iso-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
     <html>
       <head>
        <title>my title</title>
       </head>
       <body>
        <div id="explanation">
         <h3>optional Title to display in the web part</h3>
         <p>optional description to display above the links list</p>
        </div>
        <div id="subscribe"></div>
        <div id="content">
         <xsl:variable name="count" select="4"/>
         <xsl:for-each select="//*[local-name()='item'][position() &lt; 6]">
          <xsl:variable name="myURL" select="link"/>
          <div class="article" >
           <a href="{$myURL}" rel="bookmark"><xsl:value-of select="title"/></a>
          </div>
         </xsl:for-each>
        </div>
       </body>
      </html>
     </xsl:template>
    </xsl:stylesheet>
  10. Click OK.
References
Notes
  • None

3 comments:

Anonymous said...

Great post. A solution that just works if you want to customise an RSS feed in SharePoint 2103 / Office 365.

Thanks

Unknown said...

Good Stuff,

I got the output what I wanted after hours of modification to your initial code.But yeah, the code did build the base. Thanks for It.

Just a question, after few minutes of running the webpart, it gives an error:

"Webpart has timed out", tested on SPS 2013 (OnPrem) and SharePoint Online.

Please assist.

Al said...

Try unchecking the "automatically detect internet settings" in internet explorer for the web application service account (eg, spApp) and farm service account (eg, spFarm).