Skip to content

Instantly share code, notes, and snippets.

@mwfrost
Created February 8, 2011 15:09
Show Gist options
  • Select an option

  • Save mwfrost/816554 to your computer and use it in GitHub Desktop.

Select an option

Save mwfrost/816554 to your computer and use it in GitHub Desktop.
Use XPath 2.0 syntax to list all the nodes in an XML file
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="text()"/>
<xsl:template match="*|@*">
<xsl:value-of select="
string-join(
distinct-values(
(//*|//@*)
/string-join(
(ancestor::node()/name(),
if (self::attribute())
then concat('@',name())
else name()),
'/')),
'&#xA;')"/>
</xsl:template>
</xsl:stylesheet>
<!-- source: http://stackoverflow.com/questions/4051987/list-every-node-in-an-xml-file -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment