Reputation: 48430
I am interested in retrieving foo
from the following XML:
<a>
<b>
<c num="2">foo</c>
<c num="3">bar</c>
</b>
</a>
Using XSLT+XPATH, I'm attempting to do something similar to:
<xsl:value-of select="a/b/c/@num=2/current()">
But I don't think that will retrieve foo
properly. Is there a better way of going about with this?
Upvotes: 1
Views: 92
Reputation: 157927
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>
Upvotes: 1