我想提取使用使用Java的XPath的HTML内容的HTML文档。在红宝石中,我可以使用nokogiri来做到这一点,如下所示。提取内容使用纯Java
xpath = '/html/body/div/div[2]/div[2]/div/div[2]/div[3]/p'
doc = Nokogiri::HTML(open('test_001_html64.html'))
doc.xpath().each do |link|
puts link.content
end
我想用纯Java做。我看着Jsoup,但找不到任何使用xpath执行此操作的文档或示例。有人可以提出一种方法吗?
感谢
许多相关的/重复 - 见http://stackoverflow.com/questions/9022140/using-xpath-contains-against-html-in-java http://stackoverflow.com/questions/3352594/querying -an-HTML页面与 - XPath的在Java的http://stackoverflow.com/questions/3361263/library-to-query-html-with-xpath-in-java – 2013-01-07 00:43:59