Java Utililty Methods XML CDATA Append

List of utility methods to do XML CDATA Append

Description

The list of methods to do XML CDATA Append are organized into topic(s).

Method

voidappendCDATA(Element parent, String content)
Adds a nested CDATA section.
Document doc = parent.getOwnerDocument();
CDATASection c = doc.createCDATASection(content);
parent.appendChild(c);
voidappendCDATAElement(Element parent, String name, String content)
Adds a nested CDATA section in a new child element.
Element e = createChildElement(parent, name);
appendCDATA(e, content);
ElementappendCDATAElement(Element parent, String tagName, String value)
append CDATA Element
Element child = appendElement(parent, tagName);
if (value == null) {
    value = "";
Node cdata = child.getOwnerDocument().createCDATASection(value);
child.appendChild(cdata);
return child;
ElementappendCDATAElement(Element parent, String tagName, String value)
Appends the CDATA element to the parent element.
Element child = appendElement(parent, tagName);
if (value == null) { 
    value = "";
Node cdata = child.getOwnerDocument().createCDATASection(value);
child.appendChild(cdata);
return child;
voidappendCDATASection(CDATASection cdataSection, StringBuffer buf)
append CDATA Section
buf.append("<![CDATA[");
buf.append(cdataSection.getData());
buf.append("]]>");
voidappendCDATASection(Node parent, String name, Object data)
append CDATA Section
Document doc = (parent.getNodeType() == Node.DOCUMENT_NODE) ? (Document) parent : parent.getOwnerDocument();
Element e = doc.createElement(name);
parent.appendChild(e);
e.appendChild(doc.createCDATASection(data.toString()));
voidappendCDATASubNode(String elementName, String nodeData, Element parentElement, Document doc)
Creates a cdata node within a created element and then attaches the date to a parent.
Element subElement = doc.createElement(elementName);
subElement.appendChild(doc.createCDATASection(nodeData));
parentElement.appendChild(subElement);
voidsetCDATA(Element element, String data)
set CDATA
if (data == null)
    data = ""; 
element.appendChild(element.getOwnerDocument().createCDATASection(data));
voidsetCData(Element element, String data)
Sets data to be the CDATA content of element
if (data == null)
    return;
CDATASection txt = getCDataNode(element);
if (txt != null)
    txt.setData(data);
else {
    txt = element.getOwnerDocument().createCDATASection(data);
    element.appendChild(txt);
...