Simple XSLT Example as an Introduction

XSLT

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html"/>
  <xsl:template match="/">
    <html>
      <head>
        <title>
          <xsl:value-of select="/rss/channel/title"/>
        </title>
      </head>
      <body>
        <xsl:apply-templates/>
      </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