在 xpath 中指定多个条件 [英] Specifying multiple conditions in xpath
问题描述
我想选择带有 I want to select all the tags with 你想像下面这样指定: 或 如果你想做一个 If you want to do a 从您的回答看来您正在尝试连接两个不同的 From your answer it looks like you are trying to concatenate two different 然而, However, 这篇关于在 xpath 中指定多个条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 的所有标签和 .所以我试图在这两个谓词之间包含 or
条件.这是行不通的.但是,如果我只包含两个类中的一个,它就可以工作.这里有什么问题?语法有问题.
<td class='blob-code blob-code-addition'> and <td class='blob-code blob-code-deletion'>
. So I am trying to include or
condition here between the two predicates. It does not work. However, if I include only one of the two classes it works . What is the problem here? Something is wrong with the syntax.By getChanges = By.xpath("//td[@class='blob-code blob-code-addition'] or //td[@class='blob-code blob-code-deletion']");
推荐答案
//td[contains(@class,'deletion') or contains(@class,'addition')]
//td[contains(@class,'blob-code blob-code-addition') or contains(@class,'blob-code blob-code-deletion')]
tag
独立搜索,那么你可以简单地使用tag
independent search then you can simply use//*[contains(@class,'blob-code blob-code-addition') or contains(@class,'blob-code blob-code-deletion')]
xpath
sxpath
scontians()
在这里不是强制性的.你也可以不用这个contians()
is not mandatory here. You also can do without this//*[(@class='blob-code blob-code-addition') or (@class='blob-code blob-code-deletion')]
登录
关闭