new Text Element - Java XML

Java examples for XML:DOM Element Create

Description

new Text Element

Demo Code


//package com.java2s;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
import org.w3c.dom.Text;

public class Main {
    public static Element newTextElement(Document doc, String nodeName,
            String value) {// w w  w .  j  av  a  2s.com
        Element result = doc.createElement(nodeName);
        Text t = doc.createTextNode(value);
        result.appendChild(t);

        return result;
    }
}

Related Tutorials