XSLT Example 2

BBC RSS

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml"
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
    indent="yes"/>

  <xsl:template match="/">
    <html>
      <head>
        <title>
          <xsl:value-of select="/rss/channel/title"/>
        </title>
      </head>
      <body>
        <h1>
          <xsl:value-of select="/rss/channel/title"/></h1>
        <p>
          <xsl:value-of select="/rss/channel/description"/>
        </p>
        <xsl:apply-templates select="/rss/channel/item" />
      </body>
    </html>
  </xsl:template>
  
  <xsl:template match="item">
    <p>
      <a href="{link}">
        <xsl:value-of select="title"/>
      </a>
      <br/>
      <xsl:value-of select="description"/>
    </p>
  </xsl:template>
  
  <xsl:template match="text()"/>
</xsl:stylesheet>

Copyright © 2002-2009 David P. Heitmeyer

Bookmark and Share