Search code examples
javaxpathcss-selectorsjsoup

Convert XPath into CssSelector for Jsoup


I have this xpath: //a[contains(text(), 'My Text')] and I want to convert it to css.

I tried with a:contains('My Text') but not work.


Solution

  • You don't have to quote the text. Just use a:contains(My Text).
    Example: https://jsoup.org/cookbook/extracting-data/selector-syntax