Java XML Child Remove All removeAllChildren(Node node)

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

Description

remove All Children

License

Open Source License

Declaration

public static boolean removeAllChildren(Node node) 

Method Source Code


//package com.java2s;
/*/*from   w  ww.  java  2 s .  c  om*/
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

import org.w3c.dom.*;

public class Main {
    public static boolean removeAllChildren(Node node) {
        Node child = node.getFirstChild();
        if (child == null)
            return false; //  already empty

        while (child != null) {
            Node nextChild = child.getNextSibling();
            node.removeChild(child);
            child = nextChild;
        }
        return true;
    }
}

Related

  1. removeAllChildren(Node node)
  2. removeAllChildren(Node node)
  3. removeAllChildren(Node node)
  4. removeAllChildren(Node node)
  5. removeAllChildren(Node node)
  6. removeAllChildren(Node node)
  7. removeAllChildren(org.w3c.dom.Element element)
  8. removeAllChildrenNotElement(Element parentElem)
  9. removeAllChildrenOfNode(Node node)