public static String xmlComment(String data){
  int idx=0;
  while (true) {
    idx=data.indexOf("--",idx);
    if (idx < 0) {
      break;
    }
    data=data.substring(0,idx + 1) + " " + data.substring(idx + 1);
  }
  if (data.indexOf('\n') >= 0) {
    return "<!--\n" + indent(data) + "-->\n";
  }
  return "<!-- " + data + " -->\n";
}

public static String xmlComment ( String data ) { int idx = 0 ; while ( true ) { idx = data . indexOf ( "--" , idx ) ; if ( idx < 0 ) { break ; } data = data . substring ( 0 , idx + 1 ) + " " + data . substring ( idx + 1 ) ; } if ( data . indexOf ( '\n' ) >= 0 ) { return "<!--\n" + indent ( data ) + "-->\n" ; } return "<!-- " + data + " -->\n" ; }
escapes a comment . if the data contains ' - - ' , it is converted to ' - - ' . the data is indented with 4 spaces if it contains a newline character .
