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 {
    /**
     * Returns the children element of an XML node
     */
    public static Iterable<Element> children(Node n) {
        final List<Element> e = new ArrayList<Element>();
        final NodeList ns = n.getChildNodes();
        for (int i = 0; i < ns.getLength(); i++) {
            if (ns.item(i) instanceof Element) {
                e.add((Element) ns.item(i));
            }
        }
        return e;
    }
}