Here you can find the source of removeChildNodes(Node node)
public static void removeChildNodes(Node node)
//package com.java2s; /*//from www . j a v a 2 s . c o m * JBoss, Home of Professional Open Source * Copyright 2005, JBoss Inc., and individual contributors as indicated * by the @authors tag. * * This is free software; you can redistribute it and/or modify it * under the terms of the JBPM BPEL PUBLIC LICENSE AGREEMENT as * published by JBoss Inc.; either version 1.0 of the License, or * (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ import org.w3c.dom.Node; public class Main { public static void removeChildNodes(Node node) { for (Node current = node.getFirstChild(), next; current != null; current = next) { next = current.getNextSibling(); node.removeChild(current); } } }