-1

I have a html files called page1.html, page2.html. In page1.html and page2.html I have a few content inside table element, now I want to extract those table contents and put it in new file called summary.html. I don't know jQuery, so how to do this from Java or Javascript. I know how to create html from Java/Javascript.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

1

If using Java, the best option I can think of is using JSOUP, a Java HTML parser library.

File input = new File("C:\\page1.html");
Document doc = Jsoup.parse(input, "UTF-8");

Element table = doc.getElementByTag("table");
Elements rows = table.getElementsByTag("tr");
for (Element row : rows) {
  String rowText = row.text();
}
Marlon Bernardes
  • 13,265
  • 7
  • 37
  • 44