Java XML Child Remove removeChildrenNode(Node node)

Here you can find the source of removeChildrenNode(Node node)

Description

remove Children Node

License

LGPL

Declaration

private static void removeChildrenNode(Node node) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    private static void removeChildrenNode(Node node) {

        NodeList children = node.getChildNodes();
        List<Node> childrenToRemove = new ArrayList<Node>();
        for (int i = 0; i < children.getLength(); i++) {
            //         node.removeChild(children.item(i));

            childrenToRemove.add(children.item(i));
        }/*from ww w  .  j  a  va  2 s.co  m*/
        for (Node child : childrenToRemove) {
            node.removeChild(child);
        }
    }
}

Related

  1. removeChildren(Node parent)
  2. removeChildren(Node parent)
  3. removeChildren(Node parent, NodeList nodelist)
  4. removeChildren(Node target)
  5. removeChildren(Node xmlNode, String name, boolean ignoreCase)
  6. removeChildrenOfType(final Node parent, final String type)
  7. removeChilds(Node node)
  8. removeNode(Node parent, Node child)