Add Child Element to parent Element - Java XML

Java examples for XML:XML Element Child

Description

Add Child Element to parent Element

Demo Code

// This program is free software; you can redistribute it and/or modify it
//package com.java2s;
import org.w3c.dom.*;

public class Main {
    public static Element AddChild(Element parent, String nodename) {
        Element childnode = parent.getOwnerDocument().createElement(
                nodename);//w ww  .j av  a  2s . c  om
        parent.appendChild(childnode);
        return childnode;
    }
}

Related Tutorials