XPath 查找属性包含文本的元素,不区分大小写? [英] XPath to find an element whose attribute contains a text, case-insensitively?
本文介绍了XPath 查找属性包含文本的元素,不区分大小写?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<root>
// other nodes
<a href="/PatternFramework/Pages/LogOut.aspx?np=/sites/novatestsite/Home.aspx" slick-uniqueid="92">Sign out</a>
</root>
如何编写返回 href
包含logout.aspx"的 a
标签的 xpath?
How to write an xpath which returns the a
tag whose href
contains "logout.aspx"?
例如像
//a[@href[contains[., "logout.aspx"]]
推荐答案
区分大小写:
//a[contains(@href,'logout.aspx')]
XPath 2.0 不区分大小写:
Case-insensitive for XPath 2.0:
//a[contains(lower-case(@href),'logout.aspx')]
XPath 1.0 不区分大小写:
Case-insensitive for XPath 1.0:
//a[contains(translate(@href, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),'logout.aspx')]
这篇关于XPath 查找属性包含文本的元素,不区分大小写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文