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

public class Main {

    public static List<Element> readChildren(Node parentNode, String nodeName) {
        ArrayList<Element> ret = new ArrayList<Element>();
        NodeList children = parentNode.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            if (children.item(i).getNodeName().equals(nodeName))
                ret.add((Element) children.item(i));
        }
        return ret;
    }

    public static List<Element> readChildren(Node parentNode) {
        ArrayList<Element> ret = new ArrayList<Element>();
        NodeList children = parentNode.getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
            if (children.item(i) instanceof Element)
                ret.add((Element) children.item(i));
        }
        return ret;
    }
}