Java Code Examples for org.dom4j.Element.addCDATA()

The following are Jave code examples for showing how to use addCDATA() of the org.dom4j.Element class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: minlia-iot   File: AbstractAnnotationApiSerializer.java   Source Code and License Vote up 8 votes
/**
 * 添加节点
 */
private void addElement(Element rootElement, String elementName, Object obj, boolean required) {
  if (obj == null && !required) {
    return;
  }
  Assert.notNull(obj, elementName);
  Class<?> clazz = obj.getClass();
  Element element = rootElement.addElement(elementName);
  if (clazz == Integer.class || clazz == Long.class) {
    element.setText(obj.toString());
  } else {
    element.addCDATA(obj.toString());
  }
}
 
Example 2
Project: parabuild-ci   File: Dom4JXMLOutput.java   Source Code and License Vote up 7 votes
public void writeCDATA(String cdata) {
	Element top = (Element) stack.getLast();
	top.addCDATA(cdata);
}