我知道标题很糟糕,但是我什至不知道该如何表达我想要的东西。这是代码:
<div class="card card-list">
<a href="javascript:;" data-id="10" class="card-list-item ">
<img src="/Images/ranked/a.png" style="width:25px;">
Ranked Duel 1v1
<span class="badge">874</span>
</a>
<a href="javascript:;" data-id="11" class="card-list-item ">
<img src="/Images/ranked/b.png" style="width:25px;">
Ranked Doubles 2v2
<span class="badge">1188</span>
</a>
<a href="javascript:;" data-id="12" class="card-list-item ">
<img src="/Images/ranked/c.png" style="width:25px;">
Ranked Solo Standard 3v3
<span class="badge">1047</span>
</a>
<a href="javascript:;" data-id="13" class="card-list-item ">
<img src="/Images/ranked/d.png" style="width:25px;">
Ranked Standard 3v3
<span class="badge">1417</span>
</a>
</div>
xpath是否可以从确定的未标记文本中提取类值“徽章”?例如,我想从“排名标准3v3”文本中提取“徽章”值(1417)。 或者,如果我为“ Ranked Doubles 2v2”发布xpath,则它应返回“徽章”值1188。
答案 0 :(得分:0)
尝试在XPath下面使用,以获取“排名标准3v3”的适当值
//a[contains(., "Ranked Standard 3v3")]/span/text()
或
//text()[normalize-space()="Ranked Standard 3v3"]/following-sibling::span/text()