Java XML CDATA Add addCDATAstring(String value)

Here you can find the source of addCDATAstring(String value)

Description

add CDAT Astring

License

Open Source License

Declaration

static public String addCDATAstring(String value) 

Method Source Code

//package com.java2s;
/**//www. j  a v  a  2  s . c om
 * Created by IntelliJ IDEA.
 * User: Piek Vossen
 * Date: 17-dec-2008
 * Time: 14:38:37
 * To change this template use File | Settings | File Templates.
 * This file is part of KafSaxParser.
    
KafSaxParser is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
KafSaxParser is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with KafSaxParser.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    static public String addCDATAstring(String value) {
        String CDATAvalue = value;
        if (!value.startsWith("<![CDATA[")) {
            CDATAvalue = "<![CDATA[" + value + "]]>";
        }
        return CDATAvalue.trim();
    }
}

Related

  1. addCDATA(final String xML)
  2. addCData(String xml)
  3. addCDATAElement(Node parent, String name, String data, Attr[] attrs)
  4. addCdataNode(Element element, String tagName, String value)
  5. addChildCdataElement(Node parent, String name, String cdata)
  6. addNodeCDATAValue(Node node, String name, String value)