Home » CodeDigest


Consume RSS Feed Using XSLT Transformation in ASP.Net(RSS Reader)
Submitted By Bala Murugan
On 7/7/2010 7:03:16 AM
Tags: ASP.Net,CodeDigest  

Consume RSS Feed Using XSLT Transformation in ASP.Net


This is a small tip which helps us to display RSS XML in HTML using XSLT transformation.


Below is the xsl file that has the transformation rules to convert RSS XML to HTML.


<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
  <xsl:template match="/">
    <xsl:for-each select="//item">

            <xsl:attribute name="href">
              <xsl:value-of select="link" />
            <xsl:value-of select="title"/>
          <xsl:value-of select="description"/>



The below code will convert the RSS feed to HTML and will display in a Literal Control(ltRss) using XslCompiledTransform class.


string strXSLTFile = Server.MapPath("RSSXSLT.xslt");
XmlReader reader = XmlReader.Create("");
XslCompiledTransform objXSLTransform = new XslCompiledTransform();
StringBuilder htmlOutput = new StringBuilder();
TextWriter htmlWriter = new StringWriter(htmlOutput);
objXSLTransform.Transform(reader, null, htmlWriter);
ltRss.Text = htmlOutput.ToString();


Include System.Xml.Xsl, System.Xml and System.IO namespace for the above code to work.


Read the below article to know more on XSL and XSLT transformation,
Doing XSLT Transformation in ASP.Net


Do you have a working code that can be used by anyone? Submit it here. It may help someone in the community!!

Recent Codes
  • View All Codes..