htmlparser如何自定义UlTag标签:
代码如下:
public class UlTag extends CompositeTag {
private static final String[] mIds = new String[] {"ul"};
public String[] getIds(){
return (mIds);
}
public String[] getEnders (){
return (mIds);
}
}
标签要先注册后使用:
代码如下:
// 注册并输入HTML
PrototypicalNodeFactory p = new PrototypicalNodeFactory();
p.registerTag(new UlTag());
NodeFilter filter1 = new NodeClassFilter(UlTag.class);
NodeList nodes = parser.extractAllNodesThatMatch(filter1)