gpt4 book ai didi

xml - 计算XML元素中不区分大小写的某些单词的出现

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

以下是XML文件的结构-

<Datas>
<Data>
<Name>Information</Name>
<Desc>Today is Monday, the starting day of the week.</Desc>
</Data>
<Data>
<Name>Stackoverflow.com</Name>
<Desc>Yesterday 1200 questions were posted. <b>TODAY</b>, till now 1300 questions are posted. So, today will be an important day for all the senior members.</Desc>
</Data>
</Datas>


在上面的XML中,我想计算单词 today的出现。该单词可以采用任何格式,例如- TodaytodayTODAYtoDay。最后一个是不正确的,但是如果用户类型是这样,就不要错过它。

我正在使用查询-

count(/Datas/Data[contains(translate(Desc,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXY'), 'TODAY')])

结果是2,但是总共有3个!如何包括所有?

最佳答案

如果您使用的是BaseX(记得我记得的话),则可以使用非标准的ft:count,这会使生活变得更加轻松。

ft:count(//*[text() contains text "today"])


另一个好处是该查询将能够使用全文本索引,这比为每个查询标记文档要快得多。切记设置全文索引时不要大写。

关于xml - 计算XML元素中不区分大小写的某些单词的出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11823033/

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