Skip to content

Instantly share code, notes, and snippets.

@nilshoerrmann
Created June 16, 2012 06:40
Show Gist options
  • Save nilshoerrmann/2940230 to your computer and use it in GitHub Desktop.
Save nilshoerrmann/2940230 to your computer and use it in GitHub Desktop.
<data>
<entry id="1">
<title>Title 1</title>
<gallery>
<item>
<image>Image 1</image>
</item>
</gallery>
</entry>
<entry id="2">
<title>Title 2</title>
<gallery>
<item>
<image>Image 2a</image>
</item>
<item>
<image>Image 2b</image>
</item>
</gallery>
</entry>
</data>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/data">
<xsl:apply-templates select="entry" />
</xsl:template>
<xsl:template match="entry">
<!-- Get title -->
<xsl:value-of select="title" />
<!-- Get images -->
<xsl:apply-templates select="gallery/item/image" />
</xsl:template>
<xsl:template match="item/image">
<xsl:value-of select="." />
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment