Magic:

Edit De...">

Getting the value of a brother / sister node

Let's say on the page I have many repetitions:

<div class="entry"> <h4>Magic:</h4> <a>Edit</a> <a>Delete</a> </div> 

But nodeValue of h4 not repeating. How to get nodeValue a based on h4 nodeValue tag? Get the contents of the sister nodes a h4, where the content of h4 is Magic:

+4
source share
1 answer

Use this XPath:

 //div/h4[. = 'Magic:']/following-sibling::a[1] 

It selects 1 st the next sibling a from h4 with a value of Magic:

+5
source

Source: https://habr.com/ru/post/1394851/


All Articles