Mega Code Archive

 
Categories / Java / XML
 

Moves the content of the given element to the given element

import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Utils {   /**    *     */   public static void moveContent(Element from, Element to) {       // lets move the child nodes across       NodeList childNodes = from.getChildNodes();       while (childNodes.getLength() > 0) {           Node node = childNodes.item(0);           from.removeChild(node);           to.appendChild(node);       }   } }