Let's imagine the following structure :
<div class="text">
plainjkhtext-identifsdficccccator-123
<img src="#" />
PLAINTEXT-identificator-123
<img src="1" />
</div>
<div>
<img src="2" />
<img src="1" />
</div>
And this XPath:
//div[@class, "text"]/text()[contains(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'), 'plaintext-identificator-123')]/following-sibling::img[position()<3]
Basically, this gets two <img>
elements after "plaintext-identificator-123"
text.
I need to get the <img>
elements even if they don't have the same parent.
<div class="text">
plainjkhtext-identifsdficccccator-123
<img src="#" />
PLAINTEXT-identificator-123
<b><img src="1" /></b>
</div>
<div>
<img src="2" />
<img src="1" />
</div>
I cannot use "following" axis though because that would get the <img>
element from the second <div>
, which doesn't even have the "text" class.