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 context Node node.

License

Open Source License

Parameter

Parameter Description
node to remove all children from

Declaration

public static void removeAllChildNodes(Node node) 

Method Source Code


//package com.java2s;
/*/* w  ww .  jav a 2s . c  o m*/
 * Copyright (c) 2004-2012 The YAWL Foundation. All rights reserved.
 * The YAWL Foundation is a collaboration of individuals and
 * organisations who are committed to improving workflow technology.
 *
 * This file is part of YAWL. YAWL is free software: you can
 * redistribute it and/or modify it under the terms of the GNU Lesser
 * General Public License as published by the Free Software Foundation.
 *
 * YAWL is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
 * Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with YAWL. If not, see <http://www.gnu.org/licenses/>.
 */

import org.w3c.dom.*;

public class Main {
    /**
     * Removes all child nodes from the context Node node.
     * @param node to remove all children from
     */
    public static void removeAllChildNodes(Node node) {
        NodeList children = node.getChildNodes();
        for (int j = children.getLength() - 1; j >= 0; node.removeChild(children.item(j)), j--)
            ;
    }
}

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)
  6. removeAllChildren(Element node, String elementName)
  7. removeAllChildren(final Element element)