我得到了这个HTML:
<tr>
<td>
Some
<strong>
text
</strong>
<em>
and more
</em>
</td>
...
</tr>
我需要使用此文td
找到我的Some text and more
元素。我知道我可以使用此XPath表达式获取此文本:
//td//text()
但我找不到找到td
元素的解决方案。我试试这个:
//td[//text()='Some text and more']
但我收到错误。你知道一个有效的XPath表达式吗?
答案 0 :(得分:2)
首先,XPath使用正斜杠,而不是反斜杠。
其次,我相信这可能是你需要的XPath:
//td[normalize-space(.) = 'Some text and more']
你可以尝试一下吗?