Java XML Child Remove removeChildren(Element element)

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

Description

remove Children

License

Apache License

Declaration

public static void removeChildren(Element element) 

Method Source Code

//package com.java2s;
/**//w w w. j  a  v a  2  s.c o m
 *  Copyright 2005-2016 Red Hat, Inc.
 *
 *  Red Hat licenses this file to you under the Apache License, version
 *  2.0 (the "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 *  implied.  See the License for the specific language governing
 *  permissions and limitations under the License.
 */

import org.w3c.dom.Element;
import org.w3c.dom.Node;

public class Main {
    public static void removeChildren(Element element) {
        while (true) {
            Node child = element.getFirstChild();
            if (child == null) {
                return;
            }
            element.removeChild(child);
        }
    }
}

Related

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