Java XML Child Element Add appendElement(Element parent, Element child)

Here you can find the source of appendElement(Element parent, Element child)

Description

append Element

License

Apache License

Declaration

public static void appendElement(Element parent, Element child) 

Method Source Code

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

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

public class Main {
    public static Element appendElement(Element parent, String tagName) {
        Element child = parent.getOwnerDocument().createElement(tagName);
        parent.appendChild(child);/*from   w  w  w.  j a  v  a 2 s .  c  om*/
        return child;
    }

    public static Element appendElement(Element parent, String tagName, String value) {
        Element child = appendElement(parent, tagName);
        child.appendChild(child.getOwnerDocument().createTextNode(value));
        return child;
    }

    public static void appendElement(Element parent, Element child) {
        Node tmp = parent.getOwnerDocument().importNode(child, true);
        parent.appendChild(tmp);
    }
}

Related

  1. addChildren(Element element, List children)
  2. addElement(Element parent, Element child)
  3. addElement(Element parent, Element childElement)
  4. addElementChildTo(Element parent, String nsURI, String qualifiedName)
  5. appendElement(Element parent, Element child)
  6. appendTextNode(Node parent, String child)