Search code examples
xpathhrefcontains

How to get number from link using xpath


I am using this to get the number or all the href:

//chrome

$x("(//ul[@class='pagination']//li/a[contains(.,'Seguinte')]/@href)");

The page has this:

<ul class="pagination">
  <li><a href="http://www.website.com/fornecedores--2">Seguinte</a></li>
</ul>

I want the text of href "http://www.website.com/fornecedores--2".
What i am doing wrong?


Solution

  • You may use substring-after() to get the part of the href attribute after the --:

    substring-after(//ul[@class='pagination']//li/a[contains(.,'Seguinte')]/@href, '--')