Monday, October 13, 2003 11:17 PM bart

To RSS or not to RSS

What is it?

RSS stands for RDF Site Summary, an XML-based system to retrieve the actual contents of another site in a client-application (for example, a Windows Forms client reader application). Real techies want to know what RDF is of course, okay here it is: Resource Description Framework. I like RSS very much, it can provide the latest news from other site on your own site, which is very handy to centralize things on one location. For example, I made an RSS reader application in ASP.NET on www.bartdesmet.net/news. You'll find news of ZDNet Belgium and MSDN (both worldwide and local) over there. Last week MSDN Belux released RSS on its site as well. You'll find more info on http://www.microsoft.com/belux/nl/msdn/rssfeed.mspx.

How to consume it?

This is not difficult at all. Use an ASP.NET Xml control (asp:Xml) and set both the Document and Transform properties. The Document property should point to the XmlDocument instance for the XML source file; the Transform points to an XslTransform instance which takes an XSLT and transforms the source XML to HTML. Here's a little example:

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<%@ OutputCache Duration="60" varyByParam="*" %>

<html>

<script language="VB" runat="server">
    Sub Page_Load(Sender As Object, E As EventArgs)
        Dim doc As XmlDocument = New XmlDocument()
 Dim URL As String = "
http://www.microsoft.com/belux/msdn/rss.aspx"
 Try
         doc.Load(URL)
 Catch
  Response.Write("Invalid RSS feed")
  Return
 End Try

        Dim trans As XslTransform = new XslTransform()
        trans.Load(Server.MapPath("msdnbe.xsl"))

        xml1.Document = doc
        xml1.Transform = trans
    End Sub
</script>

<body>
    <form runat=server>
        <asp:Xml id="xml1" runat="server" />
    </form>
</body>

</html>

and here's the .xsl file:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/rss/channel">
 <b><font face="verdana" size="4"><xsl:value-of select="title" /></font></b><br/>
 <i><font face="verdana" size="3"><xsl:value-of select="description" /></font></i><br/><p/>

 <xsl:apply-templates select="item" />
  </xsl:template>

  <xsl:template match="item">
 <b><font face="verdana" size="3"><xsl:value-of select="title" /></font></b>
 <font face="verdana" size="1"><i> (<xsl:value-of select="pubDate" />)</i></font><br/>
 <font face="verdana" size="2"><xsl:value-of select="description" /></font><br/>
 <font face="verdana" size="1"><a href="{link}">More...</a></font><hr/>
  </xsl:template>
</xsl:stylesheet>

Remark: use ASP.NET caching to improve the performance of the page (avoiding the need to go to the XML source on every request).

Happy RSSing ;-)

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Filed under: ,

Comments

# re: To RSS or not to RSS

Sunday, October 19, 2003 12:05 PM by bart

RSS is the abbreviation for many things. I personnally like Really Simple Syndication, but technically it stands close to RDF. I guess this is why you chose this description.

# MSDN TV on RSS

Saturday, November 22, 2003 12:56 PM by TrackBack

# re: To RSS or not to RSS

Friday, February 27, 2004 4:40 AM by bart

Thank you for the RSS

# comment

Tuesday, November 02, 2004 8:44 AM by bart

generall it is used in the application of linking between one system to another but specially in the case of some web application.xml is the very good example of this thing.

# re: To RSS or not to RSS

Friday, November 26, 2004 12:52 PM by bart

hi friend, it seems that i am in different site,
oh no its the same site where I wanna go but no comments
are appearing here related to the topic. May be I am wrong
but friend got your site while searching blog in search
engine and it is nice to say that i visited ur site
in my friend's house who is layout controller
of website's. He told me that this particular
site contain reasnable layouts and good contents
which is relevant to this site. Rarely we get this
type of site. Really appreciates your blog page. Thnks.