Kirk Evans Blog

.NET From a Markup Perspective

Aggregate RSS from SharePoint

Aggregate RSS from SharePoint

  • Comments 3

Aggregating RSS from SharePoint is actually fairly simple, you just need an XSLT stylesheet to style the XML to the HTML that you want.

  1. Add an XML Web Part (ships with SharePoint) to your page
  2. Once added, click the “open the tool pane in editor” link in the newly added web part.
  3. In the XML Link text box, enter the URL for the RSS feed.  For instance, http://blogs.xmladvice.com/MainFeed.aspx.
  4. Click the XSL Editor button to open a new window to enter the XSLT markup in.  Here is an example that mimics the look of ScottW's .Text main feed:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl=“http://www.w3.org/1999/XSL/Transform“> 

<xsl:output method="html"/>
 <xsl:template match="/">
  <style>
   #main
   {
    font-family:Trebuchet MS;
    background-color : White;
    border : 1px solid #666;
    font-size : 0.85em;
   }
   a
   {
    color:blue;
    text-decoration:none;
   }
   a:hover
   {
    color:brown;
    text-decoration:underline;
   }
   
   #main h2
   {
    margin : 0px;
    background-color : #B6C9E7;
    padding : 3px;
    border-bottom : 1px solid #666;
    font-family : Verdana;
    font-size : 0.8em;
    text-transform: uppercase;
   }
   #main h3
   {
    font-family : Verdana;
    background-color : #E5EEF7;
    padding : 2px;
    border-top : 1px solid #666;
    border-bottom : 1px dashed #666;
    padding-left : 10p
   }
   #main .byline
   {
      border-top: 1px dashed #666;

   }
   .postTitle a
   {
    color:black;
   }
   .postTitle a:hover
   {
    color:black;
    text-decoration:none;
   }
  </style>
  <xsl:apply-templates select="rss"/>
 </xsl:template>
 <xsl:template match="rss">
  <div style="font-family:Tahoma" id="main">
   <xsl:apply-templates select="channel"/>
  </div>
 </xsl:template>
 <xsl:template match="channel">
  <h1>
   <xsl:value-of select="title"/>
  </h1>
  <h2>
   <a href="{link}" target="_blank" title="{description}">
    <xsl:value-of select="description"/>
   </a>
  </h2>
  <xsl:apply-templates select="item"/>
 </xsl:template>
 <xsl:template match="item">
  <h3 class="postTitle">
   <a href="{link}" target="_blank" title="{title}">
    <xsl:value-of select="title"/>
   </a>
  </h3>
  <div>
   <span>
    <xsl:value-of select="description" disable-output-escaping="yes"/>
   </span>
  </div>
  <div class="byline">
   <span>
    <xsl:text>Posted </xsl:text>
    <xsl:value-of select="pubDate"/>
    <xsl:text> @ </xsl:text>
    <a href="{source/@url}" name="source">
     <xsl:value-of select="source"/>
    </a>
   </span>
  </div>
 </xsl:template>
</xsl:stylesheet>

 

  • or use a web part like feedreader :-)
  • Kirk Allen has provided an XSLT stylesheet to transform an RSS feed in a SharePoint XML Web Part ...
  • See http://playground.doesntexist.org for a couple of XSLT stylesheets released a couple of days ago doing exactly the same.
Page 1 of 1 (3 items)
Leave a Comment
  • Please add 5 and 4 and type the answer here:
  • Post
Translate This Page
Search
Archive
Archives