java---获取html中的标签name

1.需要下载Jsoup jar包

public final static void parseResume(String fileName) throws IOException {
// 获得document对象
Document document = Jsoup.parse(new File(fileName), "utf-8");
Elements images = document.body().select("ThreadGroup");
Elements rows = images.select("ThreadGroup[guiclass=ThreadGroupGui]");
Elements children=rows.get(0).children();
JSONObject js = new JSONObject();

for(Element child:children ){
//System.out.println(child.attr("name")+" "+child.text());
js.put(child.attr("name"),child.text());
}
System.out.println(js);
}

沫笙
原文地址:https://www.cnblogs.com/wendy-0901/p/14293569.html