【发布时间】:2016-07-14 21:14:46
【问题描述】:
给定以下 xml:
<orders>
<order>
<productName quantity="10">Blender</productName>
<total price="20">200</total>
</order>
<order>
<productName quantity="2">Computer</productName>
<total price="1000">2000</total>
</order>
<order>
<productName quantity="3">Scanner</productName>
<total price="800">2400</total>
</order>
</orders>
我想计算数量大于2的所有订单的总和。经过几个小时的尝试,我终于放弃了。这是我想出的解决方案之一(当然不行,返回0):
xsl:value-of select="sum(order/productName[@quantity>2]/total)"
请帮忙!
【问题讨论】: