tags:

views:

260

answers:

2

I want to extract only the leaf nodes from an XML document (i.e., only elements that have no children). Has anyone written an xslt to do this?

A: 

Using axes in XPath:

<xsl:apply-templates select="//you-node-spec[not(child::*)]" />
Dewfy
+1  A: 
SELECT="*[not(*)]"

Should give you anything without a child.

Irfy
This worked for me. Though I had to use 'SELECT="//*[not(*)]"'. I'm a xslt newbie and don't why the '//' part is necessary, but I'm still learning. Thanks for the help.
Great Kindness
The "//" is so that it will find the condition "*[not(*)]" anywhere in the xml structure.
Irfy