gpt4 book ai didi

xpath - 如何编写Xpath表达式以区分结果?

转载 作者:行者123 更新时间:2023-12-03 16:37:10 25 4
gpt4 key购买 nike

我是xpath表达式的新手。在问题上需要帮助
考虑以下文档:

<tbody><tr>
<td>By <strong>Bec</strong></td>
<td><strong>Great Support</strong></td>
</tr></tbody>


在这种情况下,我必须分别查找标记内的文本。

以下是我的xpath表达式:

//tbody//td//strong/text();


它按预期评估输出:

Bec
Great Support


如何编写xpath表达式以区分结果,即 BecGreat Support

最佳答案

尚不清楚您要做什么,但是以下内容应该可以成功分别进行选择:

//tbody/tr/td[1]/strong




//tbody/tr/td[2]/strong


请注意,这种情况下很可能不需要结尾处的 text()

关于xpath - 如何编写Xpath表达式以区分结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21426046/

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