Xpath 获取介于 2 个元素之间的元素,我们不能使用 id 或文本来标识第二个标签

Xpath Get elements that are between 2 elements where we can't use an id or text to identify the 2nd tag

我和这个问题有类似的问题Xpath Get elements that are between 2 elements。但在我的具体情况下,html 可能会有所不同,我不能使用第二个元素的文本

基本上我的结构如下:

<h1>Account Information</h1>
<a class="null" href="http:...">Remarks</a>
<a class="null" href="http:...">Owner Information</a>
<b>Account Detail</b>
<a class="null" href="http:...">Industrial</a>

<a class="null" href="http:...">land</a>
<b >Transfers</b>
<a class="null" href="http:...">11111</a>
<a class="null" href="http:...">22222</a>

所以我想在 b='Account Detail' 和下一个可以改变文本的 b 之间得到 <a>

对于这种情况,我使用了 2nd answer of question above

的一个版本
//a[preceding-sibling::b='Account Detail' and following-sibling::b]

对于这种情况工作正常,因为在 b='Account Detail' 之后只有一个 b 我得到了

[Industrial,land]

但是如果我们有多个<b>后b='Account Detail'

但是如果我们有多个 <b>

<h1>Account Information</h1>
<a class="null" href="http:...">Remarks</a>
<a class="null" href="http:...">Owner Information</a>
<b>Account Detail</b>
<a class="null" href="http:...">Industrial</a>    
<a class="null" href="http:...">land</a>
<b class="">Permits</b>
 <a class="null" href="http:...">12-12-222</a>
 <a class="null" href="http:...">22-2-22</a>
<b >Transfers</b>
<a class="null" href="http:...">11111</a>
<a class="null" href="http:...">22222</a>

结果是:

[Industrial,land,12-12-222,22-2-22]

这不是期望的行为

有什么建议吗? 提前致谢

尝试在 XPath 下获取所需的节点:

//a[preceding-sibling::b[1]='Account Detail' and following-sibling::b]

preceding-sibling::b[1]='Account Detail' 打算在 'Account Detail' 内容

之前获取没有前兄弟 <b> 的锚