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

public class Main {
    public static List<String> parseChildNodesAsList(Element current, String name) {

        List<String> result = new ArrayList<String>();

        NodeList nodes = current.getElementsByTagName(name);

        for (int i = 0; i < nodes.getLength(); ++i) {

            Element e = (Element) nodes.item(i);

            Node child = e.getFirstChild();

            if (child == null)
                continue;

            result.add(child.getNodeValue());

        }

        return result;
    }
}