How to read attribute of a parent node from a chil

2019-02-02 06:02发布

问题:

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>

回答1:

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

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


标签: xslt xpath