Here you can find the source of removeElement(Element parent, String tagName)
Parameter | Description |
---|---|
parent | a parameter |
tagName | a parameter |
public static void removeElement(Element parent, String tagName)
//package com.java2s; //License from project: Apache License import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /**// ww w .j a va 2 s . co m * Remove the node from parent * * @param parent * @param tagName */ public static void removeElement(Element parent, String tagName) { NodeList nl = parent.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { Node nd = nl.item(i); if (nd.getNodeName().equals(tagName)) { parent.removeChild(nd); } } } }