Reading HTML file to DOM tree using Java

后端 未结 6 1266
无人及你
无人及你 2020-11-30 03:52

Is there a parser/library which is able to read an HTML document into a DOM tree using Java? I\'d like to use the standard DOM/Xpath API that Java provides.

6条回答
  •  自闭症患者
    2020-11-30 03:53

    Use https://jsoup.org , this is very simple and power.can read and change a html.

    Sample:

    Document doc = Jsoup.parse(page);  //page can be a file or string.
    Element main = doc.getElementById("MainView");
    Elements links = doc.select(".link");
    

    for create elements can use j2html, https://j2html.com

提交回复
热议问题