Here you can find the source of removeElementXML(Node node, short nodeType, String name)
public static void removeElementXML(Node node, short nodeType, String name)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { public static void removeElementXML(Node node, short nodeType, String name) { if (node.getNodeType() == nodeType && (name == null || node.getNodeName().equals(name))) { node.getParentNode().removeChild(node); } else {//from ww w . j av a 2 s . c o m // Visit the children NodeList list = node.getChildNodes(); for (int i = 0; i < list.getLength(); i++) { removeElementXML(list.item(i), nodeType, name); } } } }