xml - XSLT using value-of to retrieve text from node with attribute -


i interested in retrieving foo following xml:

<a>   <b>     <c num="2">foo</c>     <c num="3">bar</c>   </b> </a> 

using xslt+xpath, i'm attempting similar to:

<xsl:value-of select="a/b/c/@num=2/current()"> 

but don't think retrieve foo properly. there better way of going this?

use this:

<xsl:value-of select="/a/b/c[@num='2']" /> 

complete example:

xsl:

<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform">     <xsl:template match="/">         <xsl:value-of select="/a/b/c[@num='2']" />     </xsl:template> </xsl:stylesheet> 

xml:

<?xml version="1.0"?> <a>   <b>      <c num="2">foo</c>     <c num="3">bar</c>   </b> </a> 

Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -