CleanerProperties props = new CleanerProperties();
props.setUseCdataForScriptAndStyle( false );
props.setAllowHtmlInsideAttributes( false );
props.setPruneTags( "style, script" );
HtmlCleaner cleaner = new HtmlCleaner( props );
try {
TagNode node = cleaner.clean( new StringReader( content ) );
TagNode[] nodes = node.getElementsByName( "a", true );
for (TagNode tagnode : nodes) {
tagnode.removeAttribute( "target" );
tagnode.addAttribute( "target", "_blank" );
}
nodes = node.getElementsByName( "img", true );
for (TagNode tagnode : nodes) {
tagnode.removeAttribute( "src" );
tagnode.addAttribute( "src", "NO_IMAGE" );
}
System.out.println( node.getText() );
return cleaner.getInnerHtml( node );
} catch (IOException e) {
e.printStackTrace();
}