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.
Asked
Active
Viewed 2,159 times
-1

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

Sneha Kulkarni
- 17
- 2
-
1You can't really state that you don't know jQuery but are looking for a solution in JavaScript, can't you? ;) – Jan Groth Jul 29 '13 at 12:16
-
I'm pretty sure op is mixing up java and javascript – Amitava Jul 29 '13 at 12:18
1 Answers
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
-
thanks. how can i get specific table say table with id or class? – Sneha Kulkarni Jul 29 '13 at 12:20
-