Java XML Child Element Add addChild(Node parent, String name, String text)

Here you can find the source of addChild(Node parent, String name, String text)

Description

Utility method for adding text nodes.

License

Apache License

Declaration

private static void addChild(Node parent, String name, String text) 

Method Source Code

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

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    /**/*from   w w w.ja v  a 2s . c  o  m*/
     * Utility method for adding text nodes.
     */
    private static void addChild(Node parent, String name, String text) {
        Element child = parent.getOwnerDocument().createElement(name);
        child.appendChild(parent.getOwnerDocument().createTextNode(text));
        parent.appendChild(child);
    }
}

Related

  1. addAsFirstChild(Element element, Element newChild)
  2. AddChild(Element parent, String nodename)
  3. addChild(final Node node, final Node child)
  4. addChild(Node parent, Node child)
  5. addChild(Node parent, String namespaceURI, String childName)
  6. addChildElement(Element element, String name, Object textValue)
  7. addChildElement(Element element, String name, String text)
  8. addChildElement(Element element, String name, String text)