Java XML Child Remove All removeAllChildNodes(Node node)

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

Description

Removes all child nodes from the given node.

License

Apache License

Declaration

public static void removeAllChildNodes(Node node) 

Method Source Code

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

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

public class Main {
    /**/* w  ww .  j  av  a2s . c o  m*/
     * Removes all child nodes from the given node.
     */
    public static void removeAllChildNodes(Node node) {
        NodeList children = node.getChildNodes();
        while (children.getLength() > 0) {
            node.removeChild(children.item(0));
        }
    }
}

Related

  1. removeAllChildElements(@Nonnull final Element aElement)
  2. removeAllChildNodes(Node node)
  3. removeAllChildNodes(Node node)
  4. removeAllChildNodes(Node node, String name)
  5. removeAllChildren(Element deps)