gpt4 book ai didi

xml - XPath 中不区分大小写的匹配?

转载 作者:数据小太阳 更新时间:2023-10-29 01:37:01 24 4
gpt4 key购买 nike

例如,对于下面的 XML

<CATALOG>
<CD title="Empire Burlesque"/>
<CD title="empire burlesque"/>
<CD title="EMPIRE BURLESQUE"/>
<CD title="EmPiRe BuRLeSQuE"/>
<CD title="Others"/>
<CATALOG>

如何用 xpath 匹配前 4 条记录,如 //CD[@title='empire burlesque']。有 xpath 函数可以做到这一点吗?也接受其他解决方案,例如 PHP 函数。

最佳答案

XPath 2 有一个小写(和大写)字符串函数。这与不区分大小写不太一样,但希望它足够接近:

//CD[lower-case(@title)='empire burlesque']

如果您使用的是 XPath 1,则有一个 hack using translate .

关于xml - XPath 中不区分大小写的匹配?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2893551/

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