How to select all nodes without inner elements and without attributes in .xml with unknown structure?
Asked
Active
Viewed 579 times
0
-
2start here: http://stackoverflow.com/questions/3926589/how-to-select-all-leaf-nodes-using-xpath-expression – forty-two Jun 17 '14 at 12:51
1 Answers
1
XPATH expression to find elements without subelements nor attributes is: //[not(|@*)] You will get only elements with text(). Code that gets names of those elements is below:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<xsl:apply-templates select="//*[not(*|@*)]"/>
</xsl:template>
<xsl:template match="*|@*">
<xsl:value-of select="name()"/><xsl:text>
</xsl:text>
</xsl:template>
</xsl:stylesheet>

mg_kedzie
- 337
- 1
- 9