Reputation: 15
im pretty sure that my problem would be solved in <1 minute, but I don't get it... :(
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")
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.
Please help
Upvotes: 0
Views: 604
Reputation: 12513
Change for (Elements e : ereignisse)
to for (Element e : ereignisse)
. The items in an Elements
object are of type Element
.
Upvotes: 1