Using the XML Web Part to show your Twitter feed in SharePoint

I have put together a quick and dirty example of using the XML Web Part to display and style your Twitter RSS feed in a SharePoint page. 100% of the work is done in XSLT, all you have to do is:

  • Add an XML Web Part to your page:

 

twitter1 

  • Then for the XML Link add the RSS feed for your Twitter updates, the link for this can be found on the bottom right of your Twitter home page:

 

twitter3

 

  • Next, click the XSL Editor button and paste in the following XSLT code:

 

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output method="html" />
     <xsl:template match="rss/channel">
        <style type="text/css">
            .twit_tweet a {
                font-size: 13px;
                color: #111111;
                width: 400px;
            }
            .twit_date {
                font-size: 12px;
                color: #333333;
                font-style: italic;
            }
            .twit_holder {
                padding-bottom: 15px;
                width: 500px;
            }
        </style>
        <xsl:apply-templates select="item" />
     </xsl:template>

    <xsl:template match="item">
        <div class="twit_holder">
            <div class="twit_tweet"><a target="_blank" href="{link}"><xsl:value-of select="description" disable-output-escaping="yes"/></a></div>
            <div class="twit_date"><xsl:value-of select="substring-before(pubDate,' +0000')" /></div>
        </div>
    </xsl:template>
</xsl:stylesheet>

  • After you click OK and Apply your changes you should see your tweets styled in the XML Web Part:

 

twitter2

  • You can adjust the CSS in the XSLT to change the way the tweets look. Also, if this blows up your site, don’t say I didn’t warn you. I haven’t really tested it in production. Have fun!

6 comments:

Anonymous said...

Greate it works form me. Indeed the tweets look needs to customize no problem.

Thanks, sharing this!

Anonymous said...

Any way to limit the number of tweets that will show?

John Moss said...

I get this error

Cannot retrieve the URL specified in the XML Link property. For more assistance, contact your site administrator.

Any ideas?

Thanks

Matthew McDermott said...

Great! Thanks fo rhte XSL. Did you know that you can substitute your account name for the ID in the URL? so my public timeline is http://twitter.com/statuses/user_timeline/MatthewMcD.rss

Larry W. Virden said...

When I attempt to follow your instructions above, I end up with this message in the web part:
Failed to apply XSLT to the content.

Don said...

Thanx Randy,
Hope you don't mind me testing it out on my domain and linking back to you. www.asapsharepoint.com