2

I have HTML like this

<div>
text1
<a>link_1</a>
<a>link_2</a>
text2
<a>link_3</a>
text3
</div>

I want to get all the nodes between text1 and text2. The problem is there is no p or span tag. There are only plain text with content is text1 and text2.

How could I do this with XPATH? Thank you!

neo0
  • 592
  • 3
  • 10
  • 18

1 Answers1

4

How about this way :

/div/*
    [
        preceding-sibling::text()[normalize-space(.) = 'text1'] 
            and 
        following-sibling::text()[normalize-space(.) = 'text2']
    ]
har07
  • 88,338
  • 12
  • 84
  • 137