Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;

import org.w3c.dom.Document;

import org.w3c.dom.NodeList;

public class Main {
    public static ArrayList<String> getArrayListTextValuesByDocument(Document document, String tag) {
        ArrayList<String> result = new ArrayList<String>();

        NodeList nodeList = document.getElementsByTagName(tag);
        int length = nodeList.getLength();
        for (int i = 0; i < length; i++)
            result.add(nodeList.item(i).getTextContent());

        return result;
    }
}