Example usage for org.w3c.dom Document createTextNode

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

Introduction

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

Prototype

public Text createTextNode(String data);

Source Link

Document

Creates a Text node given the specified string.

Usage

From source file:Main.java

private static void addOneElement(Document file, String text, String elementName) {
    Element newNode = file.createElement(elementName);
    Text textMsg = file.createTextNode(text);
    newNode.appendChild(textMsg);/*from w ww.j  a va2  s .  c  o m*/
    file.getDocumentElement().appendChild(newNode);
    file.getDocumentElement().appendChild(file.createTextNode("\n  "));
}

From source file:Main.java

public static void addChildValue(Document doc, Node parent, String childName, String childValue) {
    Element element = doc.createElement(childName);
    Text text = doc.createTextNode(childValue);
    element.appendChild(text);//from   w  ww. j  a  va 2 s  .co  m
    parent.appendChild(element);
}

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);//w  ww  . j a v a2 s .c o  m
}

From source file:Main.java

public static void addDataText1(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  v  a2 s  .  com*/
}

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 a2 s  .  c o  m*/
}

From source file:Main.java

/**
 * creates two elements: - one for the tag - one for the value and appends the
 * value as the child of the tag element returns a reference to the tag
 * element. Both elements are created in the document.
 *//*from   w w w.ja v  a2 s  .c  o m*/
public static Element createTaggedElement(Document doc, String tag, String value) {
    Element tagElement = doc.createElement(tag);
    Text valueElement = doc.createTextNode(value);
    tagElement.appendChild(valueElement);
    return tagElement;
}

From source file:Main.java

public static Element createElement(String name, Object value, Document doc) {
    Element element = doc.createElement(name);
    element.appendChild(doc.createTextNode(value.toString()));
    return element;
}

From source file:Main.java

public static Element writeFloatElement(Document document, String name, float value, Element parentElement) {
    Element element = document.createElement(name);
    Text text = document.createTextNode(Float.toString(value));
    element.appendChild(text);/*from  w  w w  .  j  a  v a 2 s.c  om*/
    parentElement.appendChild(element);
    return element;
}

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;//  ww  w.j av  a2s .c  o  m
}

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;
}