public static Node removeChildren(Node node){
  if (node.getNodeType() == Node.ELEMENT_NODE) {
    NodeList children=node.getChildNodes();
    for (int i=0; i < children.getLength(); i++) {
      Node child=children.item(i);
      Node temp=node.removeChild(child);
      i--;
    }
  }
  return node;
}

public static Node removeChildren ( Node node ) { if ( node . getNodeType ( ) == Node . ELEMENT_NODE ) { NodeList children = node . getChildNodes ( ) ; for ( int i = 0 ; i < children . getLength ( ) ; i ++ ) { Node child = children . item ( i ) ; Node temp = node . removeChild ( child ) ; i -- ; } } return node ; }
removes all the children of a given node
