如何从 XSLT 中的子节点读取父节点的属性 [英] How to read attribute of a parent node from a child node in XSLT

查看:23
本文介绍了如何从 XSLT 中的子节点读取父节点的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道如何在 XSLT 中从子节点读取父节点的属性.代码:

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>

推荐答案

您可以使用.."上升"一个级别.所以:

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

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

这篇关于如何从 XSLT 中的子节点读取父节点的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆