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 List<Node> getChildNodes(Node node, String childTag) {
        ArrayList<Node> nodes = new ArrayList<Node>();
        if (node == null)
            return nodes;
        NodeList nodeList = node.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node childNode = nodeList.item(i);
            if (childNode != null && childNode.getLocalName() != null
                    && childNode.getLocalName().equals(childTag)) {
                nodes.add(childNode);
            }
        }
        return nodes;
    }
}