Java XML Child Remove removeChildren(Element parent)

Here you can find the source of removeChildren(Element parent)

Description

Remove all children from a XML parent

License

Open Source License

Parameter

Parameter Description
parent The element to remove all children from

Declaration

public static void removeChildren(Element parent) 

Method Source Code

//package com.java2s;
import org.w3c.dom.*;

public class Main {
    /**/*from www.j a v a 2 s  .co m*/
     * Remove all children from a XML parent
     *
     *
     * @param parent The element to remove all children from
     *
     *
     *
     */
    public static void removeChildren(Element parent) {

        Node node = parent.getFirstChild();
        while (node != null) {
            Node removeNode = node;
            node = node.getNextSibling();
            parent.removeChild(removeNode);
        }
    }
}

Related

  1. removeChildNodes(Node node, short... ignoreNodeTypes)
  2. removeChildNodes(Node parent)
  3. removeChildren(Element el)
  4. removeChildren(Element element)
  5. removeChildren(Element element)
  6. removeChildren(final Node node)
  7. removeChildren(Node aNode)
  8. removeChildren(Node e)
  9. removeChildren(Node node)