public static String filterXML ( String str ) { String s = str ; if ( s . contains ( "<" ) ) { // don't run slow regex unless we have to s = XML_COMMENT_PATTERN . matcher ( s ) . replaceAll ( " " ) ; s = XML_PATTERN . matcher ( s ) . replaceAll ( "" ) ; } return s ; }
Simple XML filtering for XML tags .