Java XML Element Create createElement(Element parent, String name)

Here you can find the source of createElement(Element parent, String name)

Description

helper method, creates a subelement, does not format result.

License

Apache License

Parameter

Parameter Description
parent the parent element
name the name of the new element

Return

the created element

Declaration

public static Element createElement(Element parent, String name) 

Method Source Code

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

import org.w3c.dom.Element;

import org.w3c.dom.Document;

public class Main {
    /**//w ww  .j  av a 2 s  . c o m
     * helper method, creates a subelement, does not format result.
     * 
     * @param parent
     *            the parent element
     * @param name
     *            the name of the new element
     * @return the created element
     */
    public static Element createElement(Element parent, String name) {
        Document doc = parent.getOwnerDocument();
        Element newElement = doc.createElement(name);
        parent.appendChild(newElement);
        return newElement;
    }
}

Related

  1. createElement(Document document, String name, String textContent)
  2. createElement(Document dom, String elementName, Properties attributes)
  3. createElement(Document dom, String elementName, Properties attributes)
  4. createElement(Document owner, String nsURI, String elementName, String textValue)
  5. createElement(Element parent, String elementName)
  6. createElement(Element parent, String name)
  7. createElement(Element parent, String path)
  8. createElement(Element parent, String tagName)
  9. createElement(Element parent, String tagName)