html - Finding sibling after matching node text using XPath -
consider following html.
<div class="block table__responsive-body" id="review_2"> <div class="row"> <div class="small-4 columns hide-for-large-up"> <strong>betyg</strong> </div> <div class="small-8 columns table__responsive-body-content">5<p> <strong>skapades den: </strong>28 jun 09:44</p> </div> </div> <div class="row"> <div class="small-4 columns hide-for-large-up"> <strong>produkt</strong> </div> <div class="small-8 columns table__responsive-body-content"> <a href="/products/9">volvo v50</a> </div> </div> <div class="row"> <div class="small-4 columns hide-for-large-up"> <strong>recensent</strong> </div> <div class="small-8 columns table__responsive-body-content"> <a href="/users/24">john doe</a> </div> </div> </div>
i want find succeeding div
node preceding sibling div
containing strong
node given text.
for example: given <strong>
node text find betyg
. expect return:
<div class="small-8 columns table__responsive-body-content">5<p> <strong>skapades den: </strong>28 jun 09:44</p> </div>
the following xpath describe:
//div[strong/text()[contains(., 'betyg')]]/following-sibling::div
find div
containing strong
child element, contains text betyg
. find following sibling div
.
Comments
Post a Comment