Here you can find the source of removeNodes(Element parent, NodeList elements)
public static void removeNodes(Element parent, NodeList elements)
//package com.java2s; /**// w ww. j av a 2s. co m * This file belongs to the BPELUnit utility and Eclipse plugin set. See enclosed * license file for more information. */ import java.util.ArrayList; import java.util.List; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static void removeNodes(Element parent, NodeList elements) { // Copy elements in case of NodeList is a live implementation // that would shrink while deleting elments List<Node> nodesToRemove = new ArrayList<Node>(); for (int i = 0; i < elements.getLength(); i++) { Node item = elements.item(i); if (item.getParentNode() == parent) { nodesToRemove.add(item); } } for (Node n : nodesToRemove) { parent.removeChild(n); } } }