gpt4 book ai didi

html - 通过XPath获取包装元素

转载 作者:行者123 更新时间:2023-12-03 17:36:38 27 4
gpt4 key购买 nike

我有这个标记:

<div class="whatever">
<input id="uniqueId" type="checkbox">
<label for="uniqueId">best label ever</label>
</div>


当然,我可以使用XPath通过其 id获得输入

//div[contains(@class, 'whatever')]/input[@id='uniqueId']


但是如何定位包装 div?其中可能有几个,都带有 class="whatever"

谢谢你的时间。

最佳答案

本质上,您在这里有两个条件:contains一个条件和后代一个条件。您需要将它们与and结合使用:

//div[contains(@class, 'whatever') and input[@id='uniqueId']]

关于html - 通过XPath获取包装元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28301547/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com