Popular Posts
jQuery : post/get using data() as param object <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html... android.intent.action.SCREEN_ON & android.intent.action.SCREEN_OFF First, I've tried create a receiver to receive screen on/off and register receiver on AndroidManifest.xml like below, but unfortunately ... runas RUNAS 使用方法: RUNAS [ [/noprofile | /profile] [/env] [/netonly] ] /user: program RUNAS [ [/noprofile | /profile] [/env] [/netonly] ...
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);
    }
}