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 Element createElement(Element element, String tagName, String text) {
    Document doc = element.getOwnerDocument();
    Element child = doc.createElement(tagName);
    if (text != null)
        child.setTextContent(text);//from  w  w w.j a va 2 s  .  c  o m
    element.appendChild(child);
    return child;
}

From source file:Main.java

public static final void addNodeValue(Node node, String name, String value) {
    if (value != null) {
        Document doc = node.getOwnerDocument();
        Element e = doc.createElement(name);
        e.appendChild(doc.createTextNode(value));
        node.appendChild(e);/* ww  w .  j a v  a  2 s  .c  o m*/
    }
}

From source file:Main.java

private static void addTextContent(Document doc, Element root, String param, String value) {
    Element ele = doc.createElement(param);
    ele.setTextContent(value);/*w  w w  .  ja  va 2  s .c  om*/
    root.appendChild(ele);
}

From source file:Utils.java

/**
 * Create a new element//from   w  w w . j  ava 2s.  c o m
 * @param document Document to contain the new element
 * @param name the element name
 * @return new Element
 */
public static Element createElement(Document document, String name) {
    Element element;

    return document.createElement(name);
}

From source file:Main.java

public static Node addNode(Document document, Node baseNode, String newNodeName) {
    Node newNode = document.createElement(newNodeName);
    baseNode.appendChild(newNode);/*w  w  w.jav  a  2 s . c  om*/
    return newNode;
}

From source file:Main.java

public static Element addNode(Document doc, Node parent, String name) {
    Element child = doc.createElement(name);
    parent.appendChild(child);/*from  w ww  . j  a  v a2s .  co m*/
    return child;
}

From source file:Main.java

public static Element addTemplateNode(Document document, Element parent, String name) {
    Element element = document.createElement(TEMPLATE_NODE);
    parent.appendChild(element);/*from   www  .  j a va 2s . com*/
    element.setAttribute(NAME_ATTR, name);
    return element;
}

From source file:Main.java

/**
 * Creates a child element with the given name and appends it to the element child node list.
 *///from  w  w w . ja va  2s. com
public static Element addChildElement(Element element, String childElementName, Document document) {
    Element newElement = document.createElement(childElementName);

    element.appendChild(newElement);
    return newElement;
}

From source file:Main.java

/**
 * Creates the root tag node.//from w ww  .ja  va 2  s  .c o m
 *
 * @param baseDocument
 *            the base document
 * @param rootTagName
 *            the root tag name
 * @return the element
 */
public static Element createRootTagNode(Document baseDocument, String rootTagName) {
    Element newNode = baseDocument.createElement(rootTagName);
    baseDocument.appendChild(newNode);
    return newNode;
}

From source file:Main.java

public static Element createElement(Document doc, Node parent, String tagName) {
    Element e = doc.createElement(tagName);
    parent.appendChild(e);//from  w w w .  jav  a 2 s  .com
    return e;
}