Java XML Child Element Create addChildElement(Element element, String childElementName, Document document)

Here you can find the source of addChildElement(Element element, String childElementName, Document document)

Description

Creates a child element with the given name and appends it to the element child node list.

License

Open Source License

Declaration

public static Element addChildElement(Element element, String childElementName, Document document) 

Method Source Code


//package com.java2s;
/*/* w  w w  . j a  va2 s .  c  o m*/
 * XMLUtils.java
 *
 * Copyright (c) 1998 - 2006 BusinessTechnology, Ltd.
 * All rights reserved
 *
 * This program is the proprietary and confidential information
 * of BusinessTechnology, Ltd. and may be used and disclosed only
 * as authorized in a license agreement authorizing and
 * controlling such use and disclosure
 *
 * Millennium ERP system.
 *
 */

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

public class Main {
    /**
     * Creates a child element with the given name and appends it to the element child node list.
     */
    public static Element addChildElement(Element element, String childElementName, Document document) {
        Element newElement = document.createElement(childElementName);

        element.appendChild(newElement);
        return newElement;
    }
}

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 doc, Node parent, String tag)
  4. addChildElement(Document document, String elementName, Node parentNode)
  5. addChildElementNSElement(Element element, String childElementName, Document document, String nameSpaceUrl)
  6. addChildElementValue(Element element, String childElementName, String childElementValue, Document document)
  7. addChildElementValue(Element element, String childElementName, String childElementValue, Document document)
  8. addChildEpcList(final Document document, final Element root, final String childEPCs)