I'm trying to get the xpath of an element with a similar xpath to others but has a "neighbor" element that's different . Please see example below.
<div>
<div id='a'> </div>
<span> Text here </span> #this is what i'm trying to get
</div>
<div>
<div id='b'> </div>
<span> Text here </span>
</div>
I tried using //div//span
, but this gives me the 2 spans. So i tried using //div//child::div[@id='a']//ancestor::div//child::span
, but it doesn't look pleasant and looks repetitive. Does this have a better implementation?
try
//div[div[@id='a']]/span
it says get the span
child node of all div
nodes with child node div (with an @id equal to 'a').