Popular Posts
Build an OpenVPN server on android device Preparation An android device, in this case, Sony xperia Z is used Root permission required Linux Deploy for deploy i... javax.net.ssl.SSLHandshakeException: Connection closed by peer in Android 5.0 Lollipop Recently, there is a error occurs when access website via ssl connection like below although it worked fine several days ago. // Enable SSL... netbean shortcut Ctrl + F:尋找 F3:尋找下一個字串 Ctrl + G:跳到第 N 行 Ctrl + H:取代 Tab:增加縮排 Shift + Tab:減少縮排 Ctrl + E:刪除一行 Ctrl + Shift + I:修正 import 項目 Alt + Ent...
Blog Archive
Stats
HtmlCleaner
HtmlCleaner Version : 2.1
import java.io.IOException;

import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;

public class Test {

    private String refactory(String htmlSource) {
        HtmlCleaner cleaner = new HtmlCleaner();
        // 設定清除選項
        CleanerProperties p = cleaner.getProperties();
        p.setOmitComments(false); // 不清除註解(有bug, 造成結構與原本不同)
        p.setPruneTags("style,script"); // 去掉style, script標籤

        TagNode node = null;
        try {
            node = cleaner.clean(htmlSource);
        } catch (IOException e) {
            e.printStackTrace();
        }
        // 重整結構
        return cleaner.getInnerHtml(node);
    }
}