Java XML Child Element Create addChildElement(Document doc, Node parent, String tag)

Here you can find the source of addChildElement(Document doc, Node parent, String tag)

Description

Add an Element to a Document

License

Open Source License

Declaration

public static Element addChildElement(Document doc, Node parent, String tag) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.*;

public class Main {
    /** Add an Element to a Document */
    public static Element addChildElement(Document doc, Node parent, String tag) {

        Element e = doc.createElement(tag);
        doc.importNode(e, true);/*from  ww  w  .ja va 2 s .  c  o m*/
        parent.appendChild(e);
        return e;
    }
}

Related

  1. addChild(Document doc, Node parent, String name)
  2. addChild(final Document doc, Element parent, final String childName, final String childValue)
  3. addChildElement(Document document, String elementName, Node parentNode)
  4. addChildElement(Element element, String childElementName, Document document)
  5. addChildElementNSElement(Element element, String childElementName, Document document, String nameSpaceUrl)
  6. addChildElementValue(Element element, String childElementName, String childElementValue, Document document)