Java XML Child Remove removeChildNodes(Node node)

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

Description

remove Child Nodes

License

Open Source License

Declaration

public static void removeChildNodes(Node node) 

Method Source Code

//package com.java2s;
/*//from   www .  j a  v  a  2 s .  c  o  m
 * JBoss, Home of Professional Open Source
 * Copyright 2005, JBoss Inc., and individual contributors as indicated
 * by the @authors tag.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the JBPM BPEL PUBLIC LICENSE AGREEMENT as
 * published by JBoss Inc.; either version 1.0 of the License, or
 * (at your option) any later version.
 *
 * This software 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.
 */

import org.w3c.dom.Node;

public class Main {
    public static void removeChildNodes(Node node) {
        for (Node current = node.getFirstChild(), next; current != null; current = next) {
            next = current.getNextSibling();
            node.removeChild(current);
        }
    }
}

Related

  1. removeChild(Element parent, String name)
  2. removeChild(final Node node, final Node child)
  3. removeChild(Node xmlNode, String name, boolean ignoreCase)
  4. removeChild(NodeList nodes)
  5. removeChildElements(Element parent)
  6. removeChildNodes(Node node)
  7. removeChildNodes(Node node, short... ignoreNodeTypes)
  8. removeChildNodes(Node parent)
  9. removeChildren(Element el)