jsoup is a very useful html parsing tool. When using it, you need to download the corresponding jar package.
Below is the java source code for my use jsoup to parse html tables.
Personal test available!
public void parse(){String htmlStr = "<table id=kbtable >"+ "<tr> "+ "<td width=123>"+ "<div id=12>Here is the data to be obtained1</div>"+ "<div id=13>Here is the data to be obtained2</div>"+ "</td>"+ "<td width=123>"+ "<div id=12>Here is the data to be obtained3</div>"+ "<div id=13>Here is the data to be obtained4</div>"+ "</td>"+ "</tr>"+ "</table>";Document doc = Jsoup.parse(htmlStr);// Get tableElement based on id table = doc.getElementById("kbtable");// Use the selector to select all <tr> <tr/>Elements trs = table.select("tr");//Tranquility through all <tr> <tr//For (int i = 0; i < trs.size(); ++i) {// Get a trElement tr = trs.get(i);// Get all td nodes in the row Elements tds = tr.select("td");// Select a td node for (int j = 0; j < tds.size(); ++j) {Element td = tds.get(j);// Get all divElements of the td node divs = td.select("div");// Select a divfor (int k = 0; k < divs.size(); k++) {Element div = divs.get(k);//Get text information String text = div.text();//Output to console System.out.println(text);}}}}The above example of text information in tables that use jsoup to parse html is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.