<div class="apoSoftKpiBox concrete">
<div class="apoBoxIconBar">
<div class="apoKpiBoxTop">
<h4 class="ng-binding">Development</h4>
</div>
<div class="apoKpiBoxBottom">
<div class="col-xs-12 apoKpiBoxValue shortNumber ng-binding"> 0 </div>
</div>
</div>
我想选择节点apoKpiBoxBottom但是为了这样做,第一个节点apoKpiBoxTop应该有文本&#34;开发&#34;第一
我用它来选择两个元素
//div/h4[contains(text(),'Development')]|//div[contains(text(),'0')]
答案 0 :(得分:0)
这是一个可能的XPath,它基于您尝试过的XPath和发布的HTML代码段:
//div[div/h4[contains(.,'Development')]]/div[@class='apoKpiBoxBottom']/div
<强> demo
强>
答案 1 :(得分:0)
下面应该有效:
//div[@class="apoKpiBoxTop" and .="Development"]/following-sibling::div[@class="apoKpiBoxBottom"]
答案 2 :(得分:0)
试试这个xpath
//div[@class='apoKpiBoxTop']/h4[contains(text(), 'Development')]/following::div[@class='apoKpiBoxBottom']
OR
//div[@class='apoKpiBoxTop']/h4[contains(text(), 'Development')]/..//following-sibling::div[@class='apoKpiBoxBottom']