2017-03-23 70 views
-1
<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應該有文字「發展」第一如何選擇一個節點,只有當其他節點滿足條件

我用這個選擇兩個元素

//div/h4[contains(text(),'Development')]|//div[contains(text(),'0')] 

回答

0

這是基於您嘗試XPath的一個可能的XPath和HTML片段貼:

//div[div/h4[contains(.,'Development')]]/div[@class='apoKpiBoxBottom']/div 

demo

+0

什麼是點對我n [包含(。,'Development')]? – Ian

+0

它引用當前上下文元素,它是'h4'。 – har07

0

下面應該工作:

//div[@class="apoKpiBoxTop" and .="Development"]/following-sibling::div[@class="apoKpiBoxBottom"] 
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'] 
相關問題