<root>
// other nodes
<a href="/PatternFramework/Pages/LogOut.aspx?np=/sites/novatestsite/Home.aspx" slick-uniqueid="92">Sign out</a>
</root>
如何编写一个xpath,它返回a
包含“logout.aspx”的href
标记?
例如
//a[@href[contains[., "logout.aspx"]]
答案 0 :(得分:20)
区分大小写:
//a[contains(@href,'logout.aspx')]
对XPath 2.0不区分大小写:
//a[contains(lower-case(@href),'logout.aspx')]
XPath 1.0不区分大小写:
//a[contains(translate(@href, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),'logout.aspx')]