Example usage for org.w3c.dom Document createElement

List of usage examples for org.w3c.dom Document createElement

Introduction

In this page you can find the example usage for org.w3c.dom Document createElement.

Prototype

public Element createElement(String tagName) throws DOMException;

Source Link

Document

Creates an element of the type specified.

Usage

From source file:Main.java

public static Node createTextNode(Document document, String elTag, String value) {
    Node elem = document.createElement(elTag);
    Node text = document.createTextNode(value);
    elem.appendChild(text);/*from  w ww .ja  v  a2  s  . c  o m*/
    return elem;
}

From source file:Main.java

protected static Element createElement(Document d, String tagName) {
    Element e = d.createElement(tagName);
    return e;//from  w  w  w .ja v a2  s. c  o  m
}

From source file:Main.java

public static void addTextTag(Node node, String tagName, String text) {
    Document doc = node.getOwnerDocument();
    Element elem = doc.createElement(tagName);
    elem.appendChild(doc.createTextNode(text));
    node.appendChild(elem);/*w ww. j  ava  2 s .  com*/
}

From source file:Main.java

/**
 * Create a new element in the parent node with the given local name.
 * @param parent The node to which the new element will be appended.
 * @param name The local name of the new element to be created
 * @return The newly created element.//ww  w  . j a  va  2  s  . c  om
 */
public static Element makeElement(Node parent, String name) {
    Document d = getDoc(parent);
    Element result = d.createElement(name);
    parent.appendChild(result);
    return result;
}

From source file:Main.java

public static Element addChildElement(Document doc, Node parent, String elementName) {
    Element e = doc.createElement(elementName);
    parent.appendChild(e);//from   www .j a va  2 s .co  m
    return e;
}

From source file:Main.java

public static Element createLeaf(Document doc, String name, String value) {
    Element leaf = doc.createElement(name);
    if (value != null)
        leaf.appendChild(doc.createTextNode(value));
    return leaf;/*from  ww  w .  j a  v  a2  s. c  o  m*/
}

From source file:Main.java

public static Element createLeafElement(Document doc, String eleName, String text) {
    Element ele = doc.createElement(eleName);
    if (text != null) {
        ele.appendChild(doc.createTextNode(text));
    }//from  w  w  w  .jav  a  2 s .c  om
    return ele;
}

From source file:Main.java

/**
 * Create blank Document, and insert root element with given name.
 *//*from  ww  w.j  av a 2 s . c  o m*/
public final static Document newDocument(String rootElementName) throws ParserConfigurationException {
    Document doc = newDocument();
    doc.appendChild(doc.createElement(rootElementName));

    return doc;
}

From source file:Main.java

public static Element getElement(Document document, String elementName) {
    return document.createElement(elementName);

}

From source file:Main.java

public static Element createTextElement(Document dom, String tagName, String content) {
    Element root = dom.createElement(tagName);
    if (content != null)
        root.appendChild(dom.createTextNode(content));
    return root;//from   ww w . j a v  a2  s  . c  o m
}