Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import org.w3c.dom.*;

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

public class Main {

    public static List<Node> getChildElementsByTagName(Element ele, String childEleName) {
        NodeList nl = ele.getChildNodes();
        List<Node> childEles = new ArrayList<Node>();
        for (int i = 0; i < nl.getLength(); i++) {
            Node node = nl.item(i);
            if (node instanceof Element && childEleName.equals(node.getNodeName())
                    || childEleName.equals(node.getLocalName())) {
                childEles.add(node);
            }
        }
        return childEles;
    }
}