Skip to content

Instantly share code, notes, and snippets.

@alicraigmile
Created July 23, 2013 13:37
Show Gist options
  • Save alicraigmile/6062392 to your computer and use it in GitHub Desktop.
Save alicraigmile/6062392 to your computer and use it in GitHub Desktop.
XSL to get all XPaths in a document
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="//*[not(*)]">
<xsl:for-each select="ancestor-or-self::*">
<xsl:text>/</xsl:text>
<xsl:value-of select="local-name()"/>
</xsl:for-each>
<xsl:text>|</xsl:text>
</xsl:template>
<xsl:template match="text()" />
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment