Java examples for XML:DOM Document
Encloses a string into a CDATA construct as defined in its XML documentation
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String string = "java2s.com"; System.out.println(cdata(string)); }/* w w w . ja va 2 s . co m*/ /** * Encloses a string into a CDATA construct as defined in its * <a href="http://www.w3schools.com/xml/xml_cdata.asp">documentation</a> * @param string Original string * @return String enclosed by CDATA structure */ public static String cdata(String string) { String ret = null; if (string != null) { StringBuilder sb = new StringBuilder("<![CDATA["); sb.append(string); sb.append("]]>"); ret = sb.toString(); } return ret; } }