StringBuffer prvContent = new StringBuffer();
try {
parser.setEncoding(Globals.ENC_8859_1);
parser.setInputHTML(html);
NodeList nodes = parser.extractAllNodesThatMatch(nfilter);
Node node = null;
for(int i=0;i<nodes.size();i++){
if(prvContent.length() >= max_count){
if(node instanceof TagNode){
TagNode tmp_node = (TagNode)node;
boolean isEnd = tmp_node.isEndTag();
if(!isEnd){
prvContent.setLength(prvContent.length()-tmp_node.getText().length()-2);
}
}
//��������δ�رյı�ǩ
Node parent = node;
//System.out.println("current node is . "+parent.getText());
do{
parent = parent.getParent();
//System.out.println("parent = "+parent);
if(parent==null) break;
if(!(parent instanceof TagNode)) continue;
//System.out.println("Parent node is no ended. "+parent.getText());
prvContent.append(((TagNode)parent).getEndTag().toHtml());