Java XML Element Create createText(String sValue, Node nParent)

Here you can find the source of createText(String sValue, Node nParent)

Description

This method creates a new textnode with the passed on value.

License

Apache License

Parameter

Parameter Description
sValue The value for the new textnode.
nParent The parent node.

Declaration

public static void createText(String sValue, Node nParent) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.w3c.dom.Document;

import org.w3c.dom.Node;

public class Main {
    /**/*from   w w w.j  a  va2 s .c o  m*/
     * This method creates a new textnode with the passed on value.
     *
     * @param  sValue   The value for the new textnode.
     * @param  nParent  The parent node.
     */
    public static void createText(String sValue, Node nParent) {
        if (nParent != null) {
            Document dDoc = nParent.getOwnerDocument();
            Node nTemp = dDoc.createTextNode(sValue);
            nParent.appendChild(nTemp);
        }
    }
}

Related

  1. createNode(Document doc, Element parent, String nodeName, Object[] attr)
  2. createNode(Document doc, Element parent, String nodeName, Object[] attr)
  3. createTable(Element theParent)
  4. createText(final Node parent, final String text)
  5. createText(Node parent, String tag, String text)
  6. createTextElement(Element parent, String tagName, String text)
  7. createTextElement2(Element parent, String tagName, String text)
  8. findElementElseCreateAndAttribute(Document document, Element parent, String element, String attributeName, String attributeValue)
  9. findElementElseCreateAndSetAndAttribute(Document document, Element parent, String element, String value, String attributeName, String attributeValue)