how can i retrieve the last children of an element with XSLT for example:
<zoo>
<example>
<name>A</name>
</example>
<example>
<name>B</name>
</example>
<example>
<name>C</name>
</example>
<example>
<name>D</name>
</example>
</zoo>
How can i retrieve D ? Thank you for your helps
Use an expression like:
/*/example[last()]/name
Or:
/*/example[last()]/name/text()
The following stylesheet literally just outputs D
(relying on the built-in template for text nodes):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="/*/example[last()]/name"/>
</xsl:template>
</xsl:stylesheet>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.