Java tutorial
//package com.java2s; /** * 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); } } }