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> getChildrenbyNodeName(Node parentNode, String nameOfChildrenToFind) {
        NodeList childNodes = parentNode.getChildNodes();
        List<Node> listToReturn = new ArrayList<Node>();
        for (int i = 0; i < childNodes.getLength(); i++) {
            Node currentChildNode = childNodes.item(i);
            if (currentChildNode.getLocalName().equals(nameOfChildrenToFind))
                listToReturn.add(currentChildNode);
        }
        return listToReturn;
    }
}