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']

更多相关文章

  1. 当将带有撇号的单词保存到数据库时,mysql_real_escape_string会添
  2. 使用pregex提取最后2个斜杠之间的内容
  3. 如何将带有双引号反斜杠的JSON字符串转换为Javascript对象
  4. SQL Server表中某些字段含有水平制表符、换行符、回车符、反斜杠

随机推荐

  1. 隐藏时如何暂停jquery计时器
  2. res.json返回无意中修改的输入
  3. Aptana Studio 3 IDE中有运行JavaScript
  4. 使用异步库汇编数据库中的所有标记
  5. 在angularjs中动态添加/删除checked属性
  6. HTML最简单的隐藏/显示和类过滤器
  7. javascript阻塞加载问题【转】
  8. AngularJS:登录cookie过期时如何注销
  9. 调用另一个html页面后,选择列表值不会保持
  10. 怎么javascript读取本地文件中的数据,并显