Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;
import java.util.List;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {

    public static void removeAllChilderenWithoutHeader(Node node, int remainChildCount) {
        NodeList childNodes = node.getChildNodes();
        List<Node> removeNodeList = new ArrayList<Node>();
        for (int i = remainChildCount; i < childNodes.getLength(); i++) {
            removeNodeList.add(childNodes.item(i));
        }

        for (Node childNode : removeNodeList) {
            node.removeChild(childNode);
        }

    }
}