Displaying RSS feeds in ASP.NET

Posted in ASP.NET by Sumit Thomas on February 22, 2006

[tweetmeme style=”compact”]The XML control is one of the least used controls in ASP.NET. To be honest I haven’t used it much myself. I combined my little knowledge in XSL with the XML control to create a simple RSS reader. Here is the code for the WebForm

border: 1px dotted #000000;
padding: 3px;
font-family: Arial, Verdana, Geneva;
font-size: 11px;
width: 100%;
background-color: #f7f7f7;
border: 1px solid #000000;
#header h2
color: #333333;
#header .description
font-size: 14px;
font-weight: bold;

void Page_Load(object source, System.EventArgs e)
XmlDocument xmlDoc = new XmlDocument();
rssFeed.Document = xmlDoc;
rssFeed.TransformSource = rss.xsl;


The code as you can see is very simple. We create a XmlDocument object and open the feed using it. Then we pass the document to the XML control. You would also notice that we are passing an XSL source to the XML control through it’s TransformSource property. The XSL does all the formatting of the feed data. Lets look at the XSL code now.

<table class="rssContainer">
<a href="{link}" target="_blank">
<div class="description">


<a href="{link}" target="_blank"></a>  - 

<br /><i>
<hr />

The XSL code is pretty simple as you can see. Well I definetely will consider this option when I need to display any kind of XML content again.

Technorati: , ,
Tagged with: ,

2 Responses

Subscribe to comments with RSS.

  1. xsor said, on October 15, 2006 at 1:13 am

    update for VB

    Private Sub Page_Load(ByVal source As Object, ByVal e As System.EventArgs)

    Dim xmlDoc As XmlDocument = New XmlDocument()
    rssFeed.Document = xmlDoc
    rssFeed.TransformSource = “rss.xsl”
    End Sub

  2. 2leggedspider said, on June 29, 2007 at 8:20 am

    Thanks Nikiteev 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: