How to read attribute of a parent node from a child node in XSLT

xpathxslt

Just want to know how to read an attribute of a parent node from a child node in XSLT.
code:

<A>
  <b attr1="xx">
    <c>
    </c>
  </b>
</A>

XSLT:

<xsl:template match="c">
  <xsl:value-of select="attribute of b node">
</xsl:template>

Best Answer

You can go "up" a level using "..". So:

<xsl:value-of select="../@attr1"/>
Related Topic