public CleanHtmlFunction() { this.cleaner = new HtmlCleaner(); CleanerProperties p = cleaner.getProperties(); p.setOmitComments(true); p.setTranslateSpecialEntities(true); p.setTransResCharsToNCR(true); // remove all tags that contain uninteresting content p.setPruneTags("style,script,form,object,audio,video"); }
keepWhitespaceAndCommentsInHead = true; hyphenReplacementInComment = "="; setPruneTags(null); setAllowTags(null); booleanAttributeValues = BOOL_ATT_SELF;
keepWhitespaceAndCommentsInHead = true; hyphenReplacementInComment = "="; setPruneTags(null); setAllowTags(null); booleanAttributeValues = BOOL_ATT_SELF;
props.setPruneTags(pruneTags);
private HtmlCleaner getHtmlCleaner() { HtmlCleaner htmlCleaner = new HtmlCleaner(); htmlCleaner.getProperties().setUseCdataForScriptAndStyle(false); htmlCleaner.getProperties().setPruneTags("script,style"); htmlCleaner.getProperties().setTreatUnknownTagsAsContent(true); htmlCleaner.getProperties().setOmitUnknownTags(true); return htmlCleaner; }
props.setPruneTags(pruneTags);
/** * htmlcleaner로 html string을 xml string으로 바꿔주는 메소드. * @param source * @return */ private String toXML(String source){ try { CleanerProperties props = new CleanerProperties(); props.setTranslateSpecialEntities(true); props.setOmitComments(true); props.setPruneTags("script,style"); // namespace를 무시한다. props.setNamespacesAware(false); props.setAdvancedXmlEscape(true); props.setTranslateSpecialEntities(true); HtmlCleaner cl = new HtmlCleaner(props); TagNode tagNode = cl.clean(source); source = new PrettyXmlSerializer(props).getXmlAsString(tagNode); } catch (IOException e) { logger.error("",e); } return source; } //test용
props.setNamespacesAware(this.namespacesaware); props.setHyphenReplacementInComment(this.hyphenreplacement); props.setPruneTags(this.prunetags); props.setBooleanAttributeValues(this.booleanatts);
props.setBooleanAttributeValues("empty"); props.setAllowHtmlInsideAttributes(true); props.setPruneTags("script,style");