new CDATA Element - Java XML

Java examples for XML:CDATA

Description

new CDATA Element

Demo Code


//package com.java2s;
import org.w3c.dom.Element;
import org.w3c.dom.Document;

import org.w3c.dom.CDATASection;

public class Main {
    public static Element newCDATAElement(Document doc, String nodeName,
            String value) {//  w ww .  jav  a2 s. c om
        Element result = doc.createElement(nodeName);
        CDATASection cdata = doc.createCDATASection(value);
        result.appendChild(cdata);

        return result;
    }
}

Related Tutorials