I have a XML like this
<extra>
<name>format-xml</name>
<value>excel.xls</value>
</extra>
<extra>
<name>format-java</name>
<value>hello.java</value>
</extra>
<extra>
<name>Date</name>
<value>someday</value>
</extra>
<extra>
<name>version</name>
<value>2</value>
</extra>
I would like to use XSLT to get he foamt-* name
I try the start-with, but it doesn't work
<xsl:for-each select="extra[starts-with(name(),'format-')]">
Format name: <xsl:apply-templates select="name" />
Format value: <xsl:apply-templates select="value" />
</xsl:for-each>
name()
will give you the name of the context node (which in your example is <extra>
). You are trying to match on the <name>
element's value.
Adjust your select statement to:
extra[starts-with(name,'format-')]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With