Java XML Child Element Create addElement(final Document document, final Element parentDom, final String namespace, final String name)

Here you can find the source of addElement(final Document document, final Element parentDom, final String namespace, final String name)

Description

This method creates and adds a new XML Element

License

LGPL

Parameter

Parameter Description
document root document
parentDom parent node
namespace namespace
name element name

Return

added element

Declaration

public static Element addElement(final Document document, final Element parentDom, final String namespace,
        final String name) 

Method Source Code

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

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Main {
    /**//from www .j  a va 2  s .  co m
     * This method creates and adds a new XML {@code Element}
     *
     * @param document
     *            root document
     * @param parentDom
     *            parent node
     * @param namespace
     *            namespace
     * @param name
     *            element name
     * @return added element
     */
    public static Element addElement(final Document document, final Element parentDom, final String namespace,
            final String name) {
        final Element dom = document.createElementNS(namespace, name);
        parentDom.appendChild(dom);
        return dom;
    }
}

Related

  1. addElement(Document doc, String name, Element parent)
  2. addElement(Document document, Element father, String name, String attOneName, String attOneValue, String attTwoName, String attTwoValue)
  3. addElement(Document document, Element parentElement, String elementName, String elementValue)
  4. addElement(final Document doc, final Node parent, final String name)
  5. addElement(final Document document, final Element parentDom, final String namespace, final String name)
  6. addElement(final Document document, final Element root, final String elementValue, final String elementName)
  7. addElement(final Document dom, final Element el, final String name, final String value)
  8. addElementAndSetContent(Document doc, String name, Element parent, String text)
  9. addElementChildToElement(Document doc, Element parent, String elementName)