Here you can find the source of removeAllChildren(Node node)
static public void removeAllChildren(Node node)
//package com.java2s; /******************************************************************************* * Copyright (c) 2003, 2006 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w ww. j a v a2 s . c om * IBM Corporation - initial API and implementation *******************************************************************************/ import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Remove all the children of <node> */ static public void removeAllChildren(Node node) { NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { node.removeChild(list.item(i)); } } }