gpt4 book ai didi

xpath - XQuery使用什么表达式来计算匹配字符串的数量?

转载 作者:行者123 更新时间:2023-12-03 16:03:27 25 4
gpt4 key购买 nike

我正在尝试计算包含某个单词的节点数。如何计算总匹配数?

<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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com