日期:2014-05-20 浏览次数:20655 次
public static void main(String[] args) {
String str = "<div><h3 ..>dsijiswer*dfhjgf</h3></div><table><h3>sdsd</h3></table>";
Pattern p = Pattern.compile("<h3.*?/h3>");
Matcher m = p.matcher(str);
while (m.find()) {
System.out.println(m.group());
}
}
Parser parser = Parser.createParser(content, ENCODE);
NodeFilter tableTag = new TagNameFilter("h3");
NodeList nodes = parser.extractAllNodesThatMatch(tableTag);
if (nodes != null) {
for (int i = 0; i < nodes.size(); i++) {
Node textnode = (Node) nodes.elementAt(i);
String temp1 = textnode.toHtml();
String temp2 = textnode.toPlainTextString();
}
}