htmlparser日记

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"))) {

 

posted on 2013-06-26 15:23  little fat  阅读(177)  评论(0编辑  收藏  举报