In XSLT there is the
<xsl:value-of select="expression"/>
to get the value of an element, but is there something to select the tag-name of the element?
In a situation like this:
<person>
<!-- required stuff -->
<name>Robert</name>
<!-- optional stuff, free form for future extension.
Using XMLSchema's xsd:any -->
<profession>programmer</profession>
<hobby>photography</hobby>
</person>
<xsl:for-each select="person">
<xsl:tag-of select="."/> : <xsl:value-of select="."/>
</xsl:for-each>
To get output like this:
name : Robert
profession : programmer
hobby : photography
Of course the above XSLT won't compile because
<xsl:tag-of select="expression"/>
doesn't exist. But how could this be done?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…