在 Xpath 表达式中使用计数 [英] Use of count in Xpath expressions
本文介绍了在 Xpath 表达式中使用计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有这样的 XML:(只是举个例子)
if I have an XML like this: (just to do an example)
<restaurant>
<tables>
<table id=1 />
<table id=2 />
<table id=3 />
</tables>
而且我要数表的数量,正确的Xpath表达式是:
And I have to count the number of tables, the correct Xpath expression is:
restaurant/tables/count(table)
或
count(restaurant/tables/table)
?
谢谢
推荐答案
查看 这个 Microsoft XPath count() 教程.
count(/restaurant/tables/table)
将计算上述路径中的表格元素.
will count the table elements in the above path.
这篇关于在 Xpath 表达式中使用计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文