Search code examples
htmlxmlxpath

XPath for labeled data?


I want to read the data which is inside the second div:

<div class="my-3">
  <div class="d-flex justify-content-between">Monthly:</div>
  <div>0 / 30,000</div>
</div>

In the above markup, I want to read the div which contains the string: 0 / 30,000

I was able to navigate to the first div which contains the string "Monthly:" with this XPath:

//*[normalize-space()='Monthly:']

How can I select the second div below after that?


Solution

  • Use this:

    //*[normalize-space()='Monthly:']/following-sibling::div