DZone 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

Snippets has posted 5883 posts at DZone. View Full User Profile

RSS To Html Conversion

01.16.2006
| 10253 views |
  • submit to reddit
        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

Snippets Manager replied on Fri, 2006/03/24 - 3:35pm

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