Does anyone know of an xPath to JSoup convertor? I get the following xPath from Chrome:
//*[@id=\"docs\"]/div[1]/h4/a
and would like to c
You don't necessarily need to convert Xpath to JSoup specific selectors.
Instead you can use XSoup which is based on JSoup and supports Xpath.
https://github.com/code4craft/xsoup
Here is an example using XSoup from the docs.
@Test
public void testSelect() {
String html = "" +
"a b
";
Document document = Jsoup.parse(html);
String result = Xsoup.compile("//a/@href").evaluate(document).get();
Assert.assertEquals("https://github.com", result);
List list = Xsoup.compile("//tr/td/text()").evaluate(document).list();
Assert.assertEquals("a", list.get(0));
Assert.assertEquals("b", list.get(1));
}