繁体   English   中英

确定后续兄弟姐妹的正确xpath

[英]determining the correct xpath for following sibling

我有一些HTML代码如下。 我只显示了适用的部分(前后有更多的div块,但此处无关紧要)

<div style="display: inline-block; position: absolute; top: 65px; bottom: auto; left: 5px; right: auto; width: auto; height: auto; max-width: none; max-height: none;" _afrc="2 1 6 1 start top">ID1: </div>
<div style="display: inline-block; position: absolute; top: 65px; bottom: auto; left: 89px; right: auto; width: auto; height: auto; max-width: none; max-height: none;" _afrc="3 1 6 1 start top">5134925</div>
<div style="display: inline-block; position: absolute; top: 84px; bottom: auto; left: 5px; right: auto; width: auto; height: auto; max-width: none; max-height: none;" _afrc="2 1 8 1 start top">ID2: </div>
<div style="display: inline-block; position: absolute; top: 84px; bottom: auto; left: 89px; right: auto; width: auto; height: auto; max-width: none; max-height: none;" _afrc="3 1 8 1 start top">1340921</div>

我想获取ID1(5134925)和ID2(1340921)的值,我想我会使用以下同级方法,但从搜索中无法理解。

我可以使用“ // div [contains(text(),'ID1:')]和// div [contains(text(),'ID2:')]],但我需要在其后直接找到div。我可能会使用跟随兄弟,但我不知道语法。有什么建议吗?

只需追加following-sibling::div[1]

//div[contains(text(),'ID1:')]/following-sibling::div[1]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM