Example usage for org.w3c.dom Element appendChild

List of usage examples for org.w3c.dom Element appendChild

Introduction

In this page you can find the example usage for org.w3c.dom Element appendChild.

Prototype

public Node appendChild(Node newChild) throws DOMException;

Source Link

Document

Adds the node newChild to the end of the list of children of this node.

Usage

From source file:Utils.java

/**
 * Add Text object to an Element.//  w  ww.  j  av  a 2 s  . c o m
 * @param element the containing element
 * @param text the text to add
 */
public static void addText(Element element, String text) {
    element.appendChild(element.getOwnerDocument().createTextNode(text));
}

From source file:Main.java

/**
 * add a element/*from w ww .j  a v a  2  s  .  c o m*/
 * @param root father element
 * @param child child element
 */
public static void addInfoToXML(Element root, Element child) {
    root.appendChild(child);
}

From source file:Utils.java

/**
 * Add an entity to a specified Element.
 *    (eg <code>DomUtils.addEntity(element, "nbsp");</code>)
 * @param element the containing element
 * @param entity the entity to add//from   w  ww  .  java 2 s. c  o m
 */
public static void addEntity(Element element, String entity) {
    element.appendChild(element.getOwnerDocument().createEntityReference(entity));
}

From source file:Main.java

public static final void setCDATA(Element element, String data) {
    element.appendChild(element.getOwnerDocument().createCDATASection(data != null ? data : "")); //$NON-NLS-1$
}

From source file:Main.java

public static final void setText(Element element, String data) {
    element.appendChild(element.getOwnerDocument().createTextNode(data != null ? data : "")); //$NON-NLS-1$
}

From source file:Main.java

public static void importName(Document doc1, Document doc2) {
    Element root1 = doc1.getDocumentElement();
    Element personInDoc1 = (Element) root1.getFirstChild();

    Node importedPerson = doc2.importNode(personInDoc1, true);

    Element root2 = doc2.getDocumentElement();
    root2.appendChild(importedPerson);
}

From source file:Main.java

public static Element createElementWithText(Document doc, String tagName, String text) {
    Element elem = doc.createElement(tagName);
    elem.appendChild(doc.createTextNode(text));
    return elem;/*from   w  w  w  .j  a  va2  s  . c  om*/
}

From source file:Main.java

public static void appendTextElement(Document doc, Element element, String key, String value) {
    Element newElement = doc.createElement(key);
    newElement.appendChild(doc.createTextNode(value));
    element.appendChild(newElement);//from   w  w  w.  j a  va2s.com
}

From source file:Main.java

public static void addDataText(Document doc, Node parent, String elementName, String elementData) {
    Element e = doc.createElement(elementName);
    e.appendChild(doc.createTextNode(elementData));
    parent.appendChild(e);//from ww  w .  j a va 2  s  . c o m
}

From source file:Main.java

public static void appendLeaf(Document doc, Element root, String name, String value) {
    root.appendChild(createLeaf(doc, name, value));
}