1
votes

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.

1
You can't really state that you don't know jQuery but are looking for a solution in JavaScript, can't you? ;)Jan Groth
I'm pretty sure op is mixing up java and javascriptAmitava

1 Answers

0
votes

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();
}