This is my html file
<div>
<div></div>
<div></div>
<!--Comment1-->
<div>1</div>
<div>2</div>
<div>3</div>
<!--Comment2-->
<div></div>
<div></div>
<div></div>
</div>
and I want to select divs between Comment 1 and Comment 2
With this xPath = "/div/comment()" I can select <!--Comment1--><!--Comment2-->
But I want to select this
<div>1</div>
<div>2</div>
<div>3</div>
//*[preceding-sibling::comment() and following-sibling::comment()]
Or stricter version:
//*[preceding-sibling::comment()[. = 'Comment1']
and following-sibling::comment()[. = 'Comment2']]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With