public static String escapeXmlString ( String str , boolean escapeQuots ) { if ( str == null ) { return "" ; } StringBuffer buf = new StringBuffer ( ) ; char [ ] array = str . toCharArray ( ) ; for ( int i = 0 ; i < array . length ; i ++ ) { if ( array [ i ] == ' ' || array [ i ] == ' ' || array [ i ] == ' ' || ( escapeQuots && ( array [ i ] == ' ' || array [ i ] == ' ' ) ) ) { buf . append ( "&#x" + Integer . toHexString ( array [ i ] ) + ";" ) ; } else { buf . append ( array [ i ] ) ; } } return buf . toString ( ) ; }
Returns the escaped string .