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.Document;

import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static List<String> parseXmlFile(String nodeName, Document file) {
        List<String> nodeTexts = new ArrayList<String>();
        NodeList nodes = file.getElementsByTagName(nodeName);
        for (int index = 0; index < nodes.getLength(); ++index) {
            Node node = nodes.item(index).getFirstChild();
            String nodeText = node.getNodeValue();
            nodeTexts.add(nodeText);
        }
        return nodeTexts;
    }
}