htmlparser去除html标签

	private String rep(String html) {
		StringBuffer sb = new StringBuffer();
		try
		{
	     Parser parser = Parser.createParser(html,"8859_1");
		   NodeIterator its  = parser.elements();
		   
		   while(its.hasMoreNodes())
		   {
			   Node node = (Node) its.nextNode();
			   sb.append(node.toPlainTextString());
		   }
		   return sb.toString();
		   }catch(Exception ex)
		   {
		   		ex.printStackTrace();
		   		return html;
		   }
	   }

 

你可能感兴趣的:(html)