Skip to content

Instantly share code, notes, and snippets.

@tiffyzsmile
Created June 16, 2011 21:25
Show Gist options
  • Save tiffyzsmile/1030322 to your computer and use it in GitHub Desktop.
Save tiffyzsmile/1030322 to your computer and use it in GitHub Desktop.
XSLT for reading an Atom feed
<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0"
xmlns:a="http://www.w3.org/2005/Atom"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:strip-space elements="*"/>
<xsl:output method="text"/>
<xsl:template match="*"/>
<xsl:template match="a:feed">
<xsl:text>Atom Feed: </xsl:text><xsl:value-of select="a:id"/>
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="a:entry">
<xsl:text> ----------------------------------------&#10;</xsl:text>
<xsl:text> Feed entry: </xsl:text><xsl:value-of select="a:id"/>
<xsl:text>&#10;</xsl:text>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="a:title|a:updated">
<xsl:if test="parent::a:entry">
<xsl:value-of select="' '"/>
</xsl:if>
<xsl:value-of select="local-name()"/>:<xsl:apply-templates/>
<xsl:text>&#10;</xsl:text>
</xsl:template>
</xsl:transform>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment