Java XML CDATA Add addCdataNode(Element element, String tagName, String value)

Here you can find the source of addCdataNode(Element element, String tagName, String value)

Description

add Cdata Node

License

Open Source License

Declaration

public static void addCdataNode(Element element, String tagName, String value) 

Method Source Code


//package com.java2s;
// Released under the terms of the CPL Common Public License version 1.0.

import org.w3c.dom.*;

public class Main {
    public static void addCdataNode(Element element, String tagName, String value) {
        if (value != null && !(value.equals(""))) {
            Document document = element.getOwnerDocument();
            Element titleElement = document.createElement(tagName);
            titleElement.appendChild(document.createCDATASection(value));
            element.appendChild(titleElement);
        }/*from w  w w  . j  av a 2s  .co  m*/
    }
}

Related

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