Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.List;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

public class Main {
    public static List<Element> getChildElemsListByName(final String name, final Node parent) {
        ArrayList<Element> v = new ArrayList<Element>();
        Element elem = null;
        for (Node childNode = parent.getFirstChild(); childNode != null; childNode = childNode.getNextSibling()) {
            if (childNode.getNodeType() == Node.ELEMENT_NODE) {
                if (childNode.getNodeName() == name) {
                    elem = (Element) childNode;
                    v.add(elem);
                }
            }
        }
        return v;
    }
}