Use the select
-method to select those elements in the HTML page you want.
It takes a pattern as an argument to what objects you want to select, such as a specific tag with a certain id or class.
//Creates a collection of Element objects for all span tags
Elements names = doc.select("span");
//Returns a collection of the first cells of each row
Elements names = doc.select("td:eq(0)");
Use this to select what you are looking for. Using a tool in your web browser that helps you identify tags in the HTML source can be helpful.
As to your original question on how to select instructor names, see below.
If the structure of the HTML always is the same and you are certain that the instructors name will be inside a span
-tag, then you can simply parse the text in the
Elements names = doc.select("span");
for (Element e : names) {
System.out.println("Name is: " + e.text());
}
Will print out
Name is: Instructor-1 name
Name is: Instructor-2 name