public static String xmlCData(String data){
  if (data.contains("]]>")) {
    return xmlText(data);
  }
  boolean newline=data.endsWith("\n");
  data="<![CDATA[" + data + "]]>";
  return newline ? data + "\n" : data;
}

public static String xmlCData ( String data ) { if ( data . contains ( "]]>" ) ) { return xmlText ( data ) ; } boolean newline = data . endsWith ( "\n" ) ; data = "<![CDATA[" + data + "]]>" ; return newline ? data + "\n" : data ; }
converts the data to a cdata element . if the data contains ' ] ] > ' , it is escaped as a text element .
