- Add an element node using the addElement(String name) method.
Element element = rootElement.addElement("childElement");
- Add attributes to an element node using the addAttribute(String name, String value) method.
element.addAttribute("attributeName", "attributeValue");
- Add text content to an element node using the addText(String text) method.
element.addText("This is the text content of the element");
- Add CDATA block content to an element node using the addCDATA(String text) method.
element.addCDATA("This is the CDATA content of the element");
- Add an element node and attribute in one step using the methods addElement(String name) and addAttribute(String name, String value).
Element childElement = rootElement.addElement("childElement").addAttribute("attributeName", "attributeValue");