htmlparser日记
作者:互联网
原文链接:http://www.cnblogs.com/coprince/p/3156662.html
myParser = Parser.createParser(response, "utf-8");
NodeFilter tableFilter = new NodeClassFilter(Div.class);
OrFilter lastFilter = new OrFilter();
lastFilter.setPredicates(new NodeFilter[] { tableFilter });
try {
// 获取标签为div的节点列表
nodeList = myParser.parse(lastFilter);
// 循环读取每个div
for (int i = 0; i <= nodeList.size(); i++) {
if (nodeList.elementAt(i) instanceof Div) {
// System.out.println(nodeList.elementAt(i));
Div tag = (Div) nodeList.elementAt(i);
if ((tag.getAttribute("class") != null)
&& (tag.getAttribute("class")
.equals("aaaaaa"))) {
转载于:https://www.cnblogs.com/coprince/p/3156662.html
标签:nodeList,class,tag,htmlparser,elementAt,new,Div,日记 来源: https://blog.csdn.net/weixin_30437337/article/details/98464052