org.dom4j.tree.DefaultCDATA Java Examples

The following examples show how to use org.dom4j.tree.DefaultCDATA. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XMLDocUtil.java    From boubei-tss with Apache License 2.0 5 votes vote down vote up
private static void addCDATANode(Element node, String cdataNodeName, Object value) {
    Element valueNode = new DefaultElement(cdataNodeName);
    String valueStr = value.toString();
    valueStr = valueStr.replaceAll("<!\\[CDATA\\[", "&lt;!\\[CDATA\\[");
    valueStr = valueStr.replaceAll("]]>", "]]&gt;");

    valueNode.add(new DefaultCDATA(valueStr));
    node.add(valueNode);
}
 
Example #2
Source File: XmlObjectWriter.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
private void writeValue(final Branch branch, final Object obj, final String key, final String sValue, final boolean asAttribute,
    final boolean asCDATA)
{
  if (sValue == null) {
    return;
  }
  if (asAttribute == true) {
    addAttribute((Element) branch, obj, key, sValue);
  } else if (asCDATA == true) {
    branch.addElement(key).add(new DefaultCDATA(sValue));
  } else {
    branch.addElement(key).setText(sValue);
  }
}