Java XML Child Remove All removeAllChildren(Node node)

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

Description

Remove all the children of

License

Open Source License

Declaration

static public void removeAllChildren(Node node) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2003, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:// w ww. j  a v  a2  s  .  c  om
 * IBM Corporation - initial API and implementation
 *******************************************************************************/

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

public class Main {
    /**
     * Remove all the children of <node>
     */
    static public void removeAllChildren(Node node) {
        NodeList list = node.getChildNodes();
        for (int i = 0; i < list.getLength(); i++) {
            node.removeChild(list.item(i));
        }
    }
}

Related

  1. removeAllChildNodes(Node node, String name)
  2. removeAllChildren(Element deps)
  3. removeAllChildren(Element node, String elementName)
  4. removeAllChildren(final Element element)
  5. removeAllChildren(final Node node)
  6. removeAllChildren(Node node)
  7. removeAllChildren(Node node)
  8. removeAllChildren(Node node)
  9. removeAllChildren(Node node)