Kinga Kinga - 27 days ago 5
HTML Question

xpath value with condition in previous class

I have two div classes



<div class="tooltip-series">
<span class="tooltip-series-name" style="color: rgba(255, 102, 102, 0.701961);">#1/123</span>
<span class="tooltip-series-value">68</span>
</div>
<div class="tooltip-series">
<span class="tooltip-series-name" style="color: rgba(108, 157, 198, 0.6);">#2/234</span>
<span class="tooltip-series-value">64.4</span>
</div>





And I need XPath which find values (68 or 64.4) according to given parameter (123 or 234).

Answer

Given your sample XML document, following XPath 1.0 expression will output 68:

//span[contains(., '/123')]/following-sibling::span/text()

You likely need to adapt how the parameter is found, but you should get the idea.

Comments