merge Xml Root - Android XML

Android examples for XML:XML Document

Description

merge Xml Root

Demo Code


//package com.java2s;

import org.w3c.dom.Element;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static Element mergeXmlRoot(Element rootSrc, Element rootDst) {
        NodeList nodeList = rootSrc.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            Node newNode = rootDst.getOwnerDocument()
                    .importNode(node, true);
            rootDst.appendChild(newNode);
        }/* w ww .  j ava  2  s .  c  om*/
        return rootDst;
    }
}

Related Tutorials