Here you can find the source of removeChildren(Element parent)
Parameter | Description |
---|---|
parent | The element to remove all children from |
public static void removeChildren(Element parent)
//package com.java2s; import org.w3c.dom.*; public class Main { /**/*from www.j a v a 2 s .co m*/ * Remove all children from a XML parent * * * @param parent The element to remove all children from * * * */ public static void removeChildren(Element parent) { Node node = parent.getFirstChild(); while (node != null) { Node removeNode = node; node = node.getNextSibling(); parent.removeChild(removeNode); } } }