我正在尝试<div class="initiative-section__content">...</div>
通过使用此XPath来定位内容"//*[contains(text(),'Created')]/following-sibling::*"
,但由于还有,它返回了两个元素"Created Date"
。而且我不知道如何在XPath中添加“按”。我尝试了类似的方法,但是没有用"//*[contains(text(),'Created') and contains(text(),'By')]/following-sibling::*"
有任何想法吗?
<div class="initiative-section__title">
"Created"
" By"
</div>
<div class="initiative-section__content">...</div>
测试空间的标准化字符串值中的div
元素,而不是它的子文本节点:
//div[normalize-space() = "Created By"]/following-sibling::*
请注意,您可能希望缩小以下同级测试的范围,以指定直接同级,
//div[normalize-space() = "Created By"]/following-sibling::*[1]
甚至必须是div
元素的第一个直接同级:
//div[normalize-space() = "Created By"]/following-sibling::*[1][self::div]
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句