使用xpath查找包含特定内容的span
16lz
2021-01-22
I have some span's like this:
我有一些跨度像这样:
<span>
<span>foobar</span>
<span>thisisatest</span>
</span>
I'm trying to use xpath to find the span with "thisisatest" in it.
我正在尝试使用xpath找到包含“thisisatest”的跨度。
I've tried this:
我已经试过这个:
span[text()='thisisatest']
跨度(text()= ' thisisatest ']
and it doesn't seem to be working.
它似乎并不奏效。
2 个解决方案
#1
16
Aren't you missing //
at the beginning of the XPath? One slash would mean "a span that is a child of a root node". Two slashes mean "find me any span with that text".
XPath开头的// /不是没有吗?一个斜杠将意味着“一个根节点的子空间”。两个斜杠的意思是“给我找一个有文字的跨度”。
//span[text()='thisisatest']
更多相关文章
- 当将带有撇号的单词保存到数据库时,mysql_real_escape_string会添
- 使用pregex提取最后2个斜杠之间的内容
- 如何将带有双引号反斜杠的JSON字符串转换为Javascript对象
- SQL Server表中某些字段含有水平制表符、换行符、回车符、反斜杠