Java Utililty Methods XML CDATA Add

List of utility methods to do XML CDATA Add

Description

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

Method

StringaddCDATA(final String xML)
add CDATA
String cStart = "<![CDATA[";
String cEnd = "]]>";
return new StringBuilder().append(cStart).append(xML).append(cEnd).toString();
StringaddCData(String xml)
Adds the CDATA protection to an XML String
String cdataXml = "<![CDATA[";
cdataXml += xml;
cdataXml += "]]>";
return cdataXml;
ElementaddCDATAElement(Node parent, String name, String data, Attr[] attrs)
Add a CDATA element with attributes.
Element element;
CDATASection cdata;
if (parent instanceof Document) {
    element = ((Document) parent).createElement(name);
    cdata = ((Document) parent).createCDATASection(data);
} else {
    element = parent.getOwnerDocument().createElement(name);
    cdata = parent.getOwnerDocument().createCDATASection(data);
...
voidaddCdataNode(Element element, String tagName, String value)
add Cdata Node
if (value != null && !(value.equals(""))) {
    Document document = element.getOwnerDocument();
    Element titleElement = document.createElement(tagName);
    titleElement.appendChild(document.createCDATASection(value));
    element.appendChild(titleElement);
StringaddCDATAstring(String value)
add CDAT Astring
String CDATAvalue = value;
if (!value.startsWith("<![CDATA[")) {
    CDATAvalue = "<![CDATA[" + value + "]]>";
return CDATAvalue.trim();
ElementaddChildCdataElement(Node parent, String name, String cdata)
add Child Cdata Element
Element mElement = addChildElement(parent, name);
mElement.appendChild(mElement.getOwnerDocument().createCDATASection(cdata));
return mElement;
voidaddNodeCDATAValue(Node node, String name, String value)
add Node CDATA Value
if (value != null) {
    Document doc = node.getOwnerDocument();
    Element e = doc.createElement(name);
    e.appendChild(doc.createCDATASection(value));
    node.appendChild(e);