Here you can find the source of removeDirectChildren(Node parent)
public static void removeDirectChildren(Node parent)
//package com.java2s; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static void removeDirectChildren(Node parent) { NodeList childNodes = parent.getChildNodes(); while (childNodes.getLength() > 0) { parent.removeChild(childNodes.item(0)); }//from w w w. ja va 2s.c o m } }