append New Element - Java XML

Java examples for XML:XML Element Parent

Description

append New Element

Demo Code

/*//from   w  w  w  . j  a v a2s  .com
 * Copyright (c) 2013 Nu Echo Inc. All rights reserved.
 */
//package com.java2s;

import org.w3c.dom.*;

public class Main {
    public static Element appendNewElement(Node parent, String elementName) {
        Element elementNode = parent.getOwnerDocument().createElement(
                elementName);
        parent.appendChild(elementNode);
        return elementNode;
    }
}

Related Tutorials