gpt4 book ai didi

xpath - Xpath同级文本

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

我已经尝试了好一阵子了,无法理解。我尝试使用following-sibling,但对我来说不起作用。这些类实际上是通用的。我试图使用<strong>标记中的文本来标识然后提取同级内容:

<div class="generic-class">
<p class="generic-class2">
<strong>Content title</strong>
"
Dont Need "
<br>
</p>
</div>
<div class="generic-class">
<p class="generic-class2">
<strong>Content title2</strong>
"
Needed Content "
<br>
</p>
</div>
<div class="generic-class">
<p class="generic-class2">
<strong>Content title3</strong>
"
Dont Need "
<br>
</p>
</div>
<div class="generic-class">
<p class="generic-class2">
<strong>Content title4</strong>
"
Dont Need "
<br>
</p>
</div>


我尝试使用下面的方法,但没有成功,然后我意识到文本实际上在 <p>标记中,因此它不是同级的。

normalize-space(//*[@class="generic-class"]/p/strong/following-sibling::text())


我是否可以找到 <strong>标记“ Content title2”中的文本,然后在父级中获取文本?

任何帮助都将是惊人的,谢谢!

最佳答案

这应该返回"Needed Content"

normalize-space(//p/strong[.="Content title2"]/following-sibling::text())

关于xpath - Xpath同级文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53651358/

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