Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

RSS to Html conversion (See related posts)

This file is intended to transform a RSS feed (version 0.9x or 2.0) into html code fragment to be included in a complete page.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:wfw="http://wellformedweb.org/CommentAPI/">
    <xsl:output method="html"/>
    <xsl:template match="/">
        <xsl:apply-templates select="/rss/channel"/>
    </xsl:template>
    <xsl:template match="/rss/channel">
        <h3><xsl:value-of select="title"/></h3>
        <p><xsl:value-of select="description"/></p>
        <ul>
            <xsl:apply-templates select="item"/>
        </ul>
    </xsl:template>
    <xsl:template match="/rss/channel/item">
        <li>
            <a href="{link}" title="{substring(pubDate, 0, 11)}"><xsl:value-of select="title"/></a>
            <p><xsl:value-of select="description" disable-output-escaping="yes" /></p>
        </li>
    </xsl:template>
</xsl:stylesheet>

Comments on this post

mwoodwar posts on Mar 24, 2006 at 14:43
So...do I just save this as myfile.xml , and then 'link' to it in the head of an rss file? I'm not sure how to implement this. Thanks in advance, and if possible, could you echo reponse to mark@ecotone.us

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts