Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/**
 * This file belongs to the BPELUnit utility and Eclipse plugin set. See enclosed
 * license file for more information.
 */

import java.util.ArrayList;
import java.util.List;

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

public class Main {
    public static void removeAllSubNodesExceptAttributes(Node n) {
        NodeList childNodes = n.getChildNodes();
        List<Node> childNodesToRemove = new ArrayList<Node>();

        for (int i = 0; i < childNodes.getLength(); i++) {
            Node c = childNodes.item(i);

            if (c.getNodeType() != Node.ATTRIBUTE_NODE) {
                childNodesToRemove.add(c);
            }
        }

        for (Node c : childNodesToRemove) {
            n.removeChild(c);
        }
    }
}