我正在尝试计算包含某个单词的节点数。如何计算总匹配数?
<Fruit>
<type>apple</type>
<type>orange</type>
<type>apple</type>
<type>apple</type>
</Fruit>
所以苹果的计数是3。我如何得到它。我已经能够获取信息,标准化后我可以打印出来:
<text>apple orange apple apple</text>
最佳答案
let $a := <Fruit>
<type>apple</type>
<type>orange</type>
<type>apple</type>
<type>apple</type>
</Fruit>
return
count($a/type[text() eq 'apple'])
应该可以带你到达那里
关于xpath - XQuery 使用什么表达式来计算匹配字符串的数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8434373/