Java XML Node Remove removeElementXML(Node node, short nodeType, String name)

Here you can find the source of removeElementXML(Node node, short nodeType, String name)

Description

remove Element XML

License

Apache License

Declaration

public static void removeElementXML(Node node, short nodeType, String name) 

Method Source Code

//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);
            }
        }
    }
}

Related

  1. removeAll(Node node, short nodeType, String name)
  2. removeAll(Node node, short nodeType, String name)
  3. removeContents(Node parent)
  4. removeElement(Element parent, String tagName)
  5. removeElements(Node parent, String nature)
  6. removeEmptyHeadings(Node root)
  7. removeEmptyHeadings(Node root)
  8. removeEmptyLines(Node node)
  9. removeEmptyNodes(Node node)