Can anyone recommend me a java library to allow me XPath Queries over URLs? I\'ve tried JAXP without success.
Thank you.
Use Xsoup. According to the docs, it's faster than HtmlCleaner. Example
@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));
}
Link to Xsoup - https://github.com/code4craft/xsoup