Java Utililty Methods XML Child Remove

List of utility methods to do XML Child Remove

Description

The list of methods to do XML Child Remove are organized into topic(s).

Method

voidremoveChildren(Node node)
remove Children
while (node.hasChildNodes()) {
    node.removeChild(node.getFirstChild());
voidremoveChildren(Node node)
Remove all the children from a node.
if (node != null) {
    while (node.hasChildNodes()) {
        node.removeChild(node.getFirstChild());
voidremoveChildren(Node node, String name)
Remove all children with specified name from the specified node
Node currentChild = node.getFirstChild();
while (currentChild != null) {
    final Node nextChild = currentChild.getNextSibling();
    if (currentChild.getNodeName().equals(name))
        node.removeChild(currentChild);
    currentChild = nextChild;
voidremoveChildren(Node parent)
remove Children
for (;;) {
    Node n = parent.getFirstChild();
    if (n == null) {
        break;
    parent.removeChild(n);
voidremoveChildren(Node parent)
remove Children
Node child = parent.getFirstChild();
while (child != null) {
    Node next = child.getNextSibling();
    parent.removeChild(child);
    child = next;
voidremoveChildren(Node parent, NodeList nodelist)
remove Children
for (int i = 0; i < nodelist.getLength(); i++) {
    parent.removeChild(nodelist.item(i));
voidremoveChildren(Node target)
Remove the child nodes under another node.
while (target.hasChildNodes()) {
    target.removeChild(target.getFirstChild());
ListremoveChildren(Node xmlNode, String name, boolean ignoreCase)
remove Children
List<Node> removedChildren = new ArrayList<Node>();
while (true) {
    Node removedChild = removeChild(xmlNode, name, ignoreCase);
    if (removedChild == null)
        break;
    removedChildren.add(removedChild);
return removedChildren;
...
voidremoveChildrenNode(Node node)
remove Children Node
NodeList children = node.getChildNodes();
List<Node> childrenToRemove = new ArrayList<Node>();
for (int i = 0; i < children.getLength(); i++) {
    childrenToRemove.add(children.item(i));
for (Node child : childrenToRemove) {
    node.removeChild(child);
voidremoveChildrenOfType(final Node parent, final String type)
Removes any child elements that match the type
final NodeList children = parent.getChildNodes();
for (int childIndex = 0; childIndex < children.getLength(); ++childIndex) {
    final Node child = children.item(childIndex);
    if (child.getNodeName().equals(type)) {
        parent.removeChild(child);
        break;