Java XML Child Element Create createChild(Element el, String name, boolean attach)

Here you can find the source of createChild(Element el, String name, boolean attach)

Description

Creates an element with the given name in the specified element's DOM, inserting it into the tree structure as a child of that element if the attach flag is set.

License

Open Source License

Declaration

public static Element createChild(Element el, String name, boolean attach) 

Method Source Code

//package com.java2s;

import org.w3c.dom.*;

public class Main {
    /**/* ww w.ja va 2s. co m*/
     * Creates a child element with the given name beneath the specified element.
     */
    public static Element createChild(Element el, String name) {
        return createChild(el, name, true);
    }

    /**
     * Creates an element with the given name in the specified element's DOM,
     * inserting it into the tree structure as a child of that element
     * if the attach flag is set.
     */
    public static Element createChild(Element el, String name, boolean attach) {
        Element child = el.getOwnerDocument().createElement(name);
        if (attach)
            el.appendChild(child);
        return child;
    }
}

Related

  1. addElementChildToElement(Document doc, Element parent, String elementName)
  2. addElementWithText(Document document, Element parentElement, String newElementName, String textString)
  3. appendDateNode(Document owner, Element appendElement, String name, Date date)
  4. createAndAppendChild(Element parentElement, String elementName, Properties attributes)
  5. createChild(Document document, Node parent, String childNodeName)
  6. createChild(final Element el, final String name)
  7. createChild(Node node, String elemName)
  8. createChildElement(Document doc, Element parent, String name)
  9. createChildElement(Document doc, Node node, String nodeName)