Georggroenendaal
Georggroenendaal

Reputation: 314

Jsoup element text to textview

I want to display my element to an textview.

code

   Document doc = Jsoup.parse(myURL);
   Elements name  = doc.getElementsByClass(".lNameHeader");
   for (Element nametext : name){
       String text = nametext.text();

       tabel1.setText(text);

but it displays nothing.

(the site i am parsing http://roosters.gepro-osi.nl/roosters/rooster.php?leerling=120777&type=Leerlingrooster&afdeling=12-13_OVERIG&tabblad=2&school=905)

Upvotes: 1

Views: 686

Answers (2)

Reimeus
Reimeus

Reputation: 159754

From your previous question it shows that myURL is a String. In this case you are are using the constructor Jsoup.parse(String html).

You need the one that takes a URL to make the connection:

Document doc = Jsoup.parse(new URL(myURL), 2000);
Elements name = doc.getElementsByClass("lNameHeader");

Also drop the leading . character from the class name. If you don't wish to specify a timeout you can simply use:

Document doc = Jsoup.connect(myURL).get();

Upvotes: 1

Xeon
Xeon

Reputation: 5989

Actually the class for it is:

lNameHeader

Note that first letter is not 1 (one) - it's l (letter L)

So it should be:

Elements name  = doc.getElementsByClass("lNameHeader");

Note also that JSoup getElementsByClass methods doesn't work like CSS selectors - so the . must be omitted.

Upvotes: 1

Related Questions