给定以下 XML:
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
</cd>
<cd>
<title>Still got the blues</title>
<artist>Gary Moore</artist>
<country>UK</country>
<company>Virgin records</company>
<price>10.20</price>
<year>1990</year>
</cd>
</catalog>
我想检查是否至少有一个节点的年份为“1982”。就像是:
<xsl:if test="........" ><p>passed!</p></xsl:if>
在 XPath 1.0 和 Xpath 2.0 中:
'1982' = /catalog/cd/year
变化:
XPath 1.0:
1982 = /catalog/cd/year
XPath 2.0:
1982 = /catalog/cd/year/number()
X路径=操作员 http://www.w3.org/TR/xpath20/#id-general-comparisons当它的至少一个参数是节点集(或 XPath 2.0 中的序列)时,它就非常强大。当且仅当节点集(序列)中至少一个节点的(原子化)值等于另一个参数时,结果为 true=
。这正是这个问题所要问的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)