在某些情况下,我们需要选择input[@class="some"]元素,但前提div[@class="other"]是不存在。两个元素没有共同的父元素body,当然,除了。
一旦我们的环境结果集中在 XPath 上,我们只需要 XPath 解决方案。
UPD:如果元素存在,则不应返回任何内容
Try (not tested):
input[@class="some"][not(//div[@class="other"])]
Run Code Online (Sandbox Code Playgroud)