<h2>Headline 1</h2>
<p>some text</p>
<p>some more text</p>
<ul>
<li>list item 1</li>
<li>list item 2</li>
</ul>
<p>more text</p>
<h2>Headline 2</h2>
I have the above in a webpage and I want to be able to target all elements following the first h2
that contains the text 'Headline 1'
up to but NOT including the element h2
that contains the text 'Headline 2'
.
I can target the elements like this:
//*[count(preceding-sibling::hr)=1]
but this is not specific to the text contained and so if the page ever changed then the xpath could be pointing to something totally different.
What I would like in sudo code terms is this:
give me all the elements between the header
'Headline 1'
and the header'Headline 2'
including'Headline 1'
Is this at all possible?