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.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static List<Element> getMultipleElementsByName(Node node, String name) {
        List<Element> elements = new ArrayList<Element>();
        NodeList nodeList = node.getChildNodes();
        int count = nodeList.getLength();
        for (int i = 0; i < count; i++) {
            Node child = nodeList.item(i);
            if (child instanceof Element && child.getNodeName().equals(name)) {
                elements.add((Element) child);
            }
        }
        return elements;
    }
}