Java XML Duration Add appendElement(Element parent, String type)

Here you can find the source of appendElement(Element parent, String type)

Description

creates a new element of type and appends it to parent

License

Common Public License

Declaration

public static Element appendElement(Element parent, String type) 

Method Source Code

//package com.java2s;
/*//from  w  ww .ja  v  a  2s  .  co  m
 * ====================================================================
 * This software is subject to the terms of the Common Public License
 * Agreement, available at the following URL:
 *   http://www.opensource.org/licenses/cpl.html .
 * Copyright (C) 2003-2004 TONBELLER AG.
 * All Rights Reserved.
 * You must accept the terms of that agreement to use this software.
 * ====================================================================
 *
 * 
 */

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

public class Main {
    /** creates a new element of type and appends it to parent */
    public static Element appendElement(Element parent, String type) {
        Document doc = parent.getOwnerDocument();
        Element elem = doc.createElement(type);
        parent.appendChild(elem);
        return elem;
    }
}

Related

  1. addNode(Node parentNode, String name)
  2. addText(Node parent, String value)
  3. addTextElement(Node parent, String name, String value)
  4. appendElement(Element parent, String tagName)
  5. appendElement(Element parent, String tagName, String value)
  6. appendElement(Node parent, String name)
  7. appendElement(Node parent, String name)
  8. appendElement(Node parent, String tagName)
  9. appendElementNS(Element parent, String namespaceURI, String localName)