Here you can find the source of removeAll(Node node, short nodeType, String name)
public static void removeAll(Node node, short nodeType, String name)
//package com.java2s; /**// w w w.j a v a2 s. c o m * XMLUtils.java * ---------------------------------------------------------------------------------- * * Copyright (C) 2008 www.integratedmodelling.org * Created: Jan 21, 2008 * * ---------------------------------------------------------------------------------- * This file is part of ThinklabPersistencePlugin. * * ThinklabPersistencePlugin is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * ThinklabPersistencePlugin 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. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the software; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * ---------------------------------------------------------------------------------- * * @copyright 2008 www.integratedmodelling.org * @author Ioannis N. Athanasiadis (ioannis@athanasiadis.info) * @date Jan 21, 2008 * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 * @link http://www.integratedmodelling.org **/ import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static void removeAll(Node node, short nodeType, String name) { if (node.getNodeType() == nodeType && (name == null || node.getNodeName().equals(name))) { node.getParentNode().removeChild(node); } else { // Visit the children NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { removeAll(list.item(i), nodeType, name); } } } }