xpath+ regex:匹配文本 [英] xpath+ regex: matches text
本文介绍了xpath+ regex:匹配文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试编写一个 xpath,以便仅返回带有数字文本的节点.我想使用正则表达式并希望这会起作用
I'm trying to write an xpath such that only nodes with text with numbers alone will be returned. I wanted to use regex and was hoping this would work
td[matches(text(),'[\d.]')]
谁能帮我理解我在这里做错了什么
Can anyone please help me understand what am I doing wrong here
<tr>
<td>1</td>
<td>10</td>
<td>a</td>
</tr>
推荐答案
AFAIK 目前为止 Selenium 仅支持 XPath 1.0,所以不支持 matches()
.
AFAIK so far Selenium support XPath 1.0 only, so matches()
is not supported.
你可以试试下面的:
//td[number(.) >= 0 or number(.) < 0]
将表格单元格与整数匹配
To match table cells with integers
这篇关于xpath+ regex:匹配文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文