XSL Foreach - 获取价值
以下是每条记录中的一些 XML:
<MT N="usage" V="something"/>
<MT N="usage" V="something else"/>
我尝试使用 XSLT 显示每条记录的所有这些 V 值,但在定位正确值时遇到问题。
<xsl:for-each select="MT[@N = 'usage']/@V">
<xsl:value-of select="V"/>
11
</xsl:for-each>
输出“1111”,但不显示 V 的值。我该如何瞄准呢?
干杯
Here is a bit of XML that's in each record:
<MT N="usage" V="something"/>
<MT N="usage" V="something else"/>
I'm trying to display all of these V values for each record with XSLT, but am having issues targeting the correct value.
<xsl:for-each select="MT[@N = 'usage']/@V">
<xsl:value-of select="V"/>
11
</xsl:for-each>
This outputs "1111", but the value of V isn't displayed. How do I target that?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
select="V" 可能不是一个节点。
怎么样
select="V" probably is not a node.
What about
上面的
尝试显示当前节点子元素V
的值。然而,当前节点是一个属性,并且根据定义,属性没有子节点。这就是你遇到的问题。解决方案:
现在
输出当前节点的字符串值——这可能是有意的。The
<xsl:value-of>
above is trying to display the value of an elementV
that is a child of the current node. However the current node is an attribute, and attributes by definition have no children. This is the problem that you have.Solution:
Now the
<xsl:value-of>
outputs the string value of the current node -- which was probably intended.