append XML CData Element - Java XML

Java examples for XML:XML Element Value

Description

append XML CData Element

Demo Code


//package com.java2s;

public class Main {


    public static void appendCDdataElement(StringBuilder sb,
            String tagName, String value) {
        appendTagPre(sb, tagName);/*  ww w .  j a va  2 s .  c o  m*/
        sb.append("<![CDATA[").append(value).append("]]>");
        appendTagPost(sb, tagName);
    }

    public static void appendTagPre(StringBuilder sb, String tagName) {
        sb.append("<").append(tagName).append(">");
    }

    public static void appendTagPost(StringBuilder sb, String tagName) {
        sb.append("</").append(tagName).append(">");
    }
}

Related Tutorials