Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.LinkedList;
import java.util.List;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class Main {
    public static List<org.jsoup.nodes.Element> findAllElements(String segment, String name, String attrname,
            String attrvalue) {
        List<org.jsoup.nodes.Element> ret = new LinkedList<org.jsoup.nodes.Element>();

        Document doc = Jsoup.parse(segment);
        Elements elements = doc.select(name);
        for (int i = 0; i < elements.size(); i++) {
            String value = elements.get(i).attr(attrname);
            if (value != null) {
                if (value.equals(attrvalue)) {
                    ret.add(elements.get(i));
                }
            }
        }

        return ret;
    }
}