简体   繁体   English

Java Jsoup类型错误与元素vs元素

[英]Java jsoup type error with element vs elements

im pretty sure that my problem would be solved in <1 minute, but I don't get it... :( 我很确定我的问题会在1分钟内解决,但是我不明白... :(

import java.io.IOException;
import javax.lang.model.element.Element;
import org.jsoup.*;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;

public class main {
public static void main(String[] args) {
    // TODO Auto-generated method stub
    try {
        // Load website
        Document doc = Jsoup.connect("http://de.wikipedia.org/wiki/Wikipedia:Hauptseite").get();
        Elements ereignisse = doc.select("div#hauptseite-ereignisse div.inhalt ul li");
        for (Elements e : ereignisse)
            System.out.println(e.text());   
    } catch (IOException e) {
        e.printStackTrace();
    }   
}

} }

Error: "Type mismatch: cannot convert from element type Element to Elements" (in "for"-signature") 错误:“类型不匹配:无法从元素类型Element转换为Elements”(在“ for”签名中)

My code is 90% copy-paste from an easy example and same like many questions here, but doesn't work... My problem is that I don't understand the error. 我的代码来自一个简单示例的90%复制粘贴,与此处的许多问题相同,但不起作用...我的问题是我不理解该错误。

Please help 请帮忙

Change for (Elements e : ereignisse) to for (Element e : ereignisse) . for (Elements e : ereignisse)更改for (Elements e : ereignisse) for (Element e : ereignisse) The items in an Elements object are of type Element . Elements对象中的项目类型为Element

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM