Java XML Child Remove removeChildren(Node aNode)

Here you can find the source of removeChildren(Node aNode)

Description

remove Children

License

Open Source License

Parameter

Parameter Description
aNode a parameter

Declaration

public static int removeChildren(Node aNode) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 www.isandlatech.com (www.isandlatech.com)
 * 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://from w ww  . j  a  va2 s  . c om
 *    ogattaz (isandlaTech) - initial API and implementation
 *******************************************************************************/

import org.w3c.dom.Node;

public class Main {
    /**
     * 
     * @param aNode
     * @return
     */
    public static int removeChildren(Node aNode) {

        if (aNode == null) {
            return 0;
        }
        int wNbRemoved = 0;
        Node wNode;
        while (aNode.hasChildNodes()) {
            wNode = aNode.getFirstChild();
            aNode.removeChild(wNode);
        }
        return wNbRemoved;
    }
}

Related

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