1

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)

Georggroenendaal
  • 314
  • 1
  • 14

2 Answers2

1

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.

Xeon
  • 5,949
  • 5
  • 31
  • 52
1

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();
Community
  • 1
  • 1
Reimeus
  • 158,255
  • 15
  • 216
  • 276