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:Main.java

public static void addNode(Document doc, Node parent, String name, String text) {
    Element child = doc.createElement(name);
    child.appendChild(doc.createTextNode(text));
    parent.appendChild(child);/*from  w  w  w. ja  v  a2s. c o m*/
}

From source file:Main.java

public static void createChildTextWithComment(Document doc, Element elem, String name, String value,
        String comment) {/*from  w w  w  . ja v  a2s.c  om*/
    Element child = doc.createElement(name);
    child.appendChild(doc.createTextNode(value == null ? "" : value));
    Comment c = doc.createComment(comment);
    elem.appendChild(c);
    elem.appendChild(child);

}

From source file:Main.java

public static Node addTag(Document doc, Node e, String index, String value) {
    org.w3c.dom.Element tag = doc.createElement(index);
    tag.appendChild(doc.createTextNode(value));
    return e.appendChild(tag);
}

From source file:Main.java

public static Node addTag(Document doc, String index, String value) {
    org.w3c.dom.Element tag = doc.createElement(index);
    tag.appendChild(doc.createTextNode(value));
    return doc.appendChild(tag);
}

From source file:Main.java

/**
 * /*from   w  w  w .ja v a2  s.co m*/
 * @param doc
 * @param elem
 * @param name
 * @param value
 * @param comment
 */
public static void createChildTextWithComment(Document doc, Element elem, String name, String value,
        String comment) {
    Element child = doc.createElement(name);
    child.appendChild(doc.createTextNode(value == null ? "" : value));
    Comment c = doc.createComment(comment);
    elem.appendChild(c);
    elem.appendChild(child);

}

From source file:Main.java

public static Element addElement(final Document dom, final Element el, final String name, final String value) {
    Element newElement = dom.createElement(name);
    newElement.appendChild(dom.createTextNode(value));
    el.appendChild(newElement);/*from   w  ww  . jav a 2s. co  m*/
    return el;
}

From source file:Main.java

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);
    }/*  www.  j av a2  s.  c om*/
}

From source file:Main.java

public static Element createElemWithText(Document ownerDoc, String tagName, String text) {
    Element newElem = ownerDoc.createElement(tagName);
    newElem.appendChild(ownerDoc.createTextNode(text));
    return newElem;
}

From source file:Main.java

public static Element createElemWithCDATA(Document ownerDoc, String tagName, String cdata) {
    Element newElem = ownerDoc.createElement(tagName);
    newElem.appendChild(ownerDoc.createCDATASection(cdata));
    return newElem;
}

From source file:Main.java

public static Element addCDataElement(final Document dom, final Element el, final String name,
        final String value) {
    Element newElement = dom.createElement(name);
    newElement.appendChild(dom.createCDATASection(value));
    el.appendChild(newElement);//from   ww w.ja  va  2s .  c  o  m
    return el;
}