I am trying to parse the html of the following URL:
http://ocw.mit.edu/courses/aeronautics-and-astronautics/16-050-thermal-energy-fall-2002/
to obtain the text of the "< p >" tag which contains the name of an instructor. The required information is located inside "< p >" tags but I am unable to retrieve the tags using JSoup. I have no idea what I am doing wrong because when I save the tag in an Element object lets call it 'b' and I call b.getAllElements() it doesn't show
as one of the elements. Isn't that what the getAllElements() method of Jsoup does? If not could someone please explain to me the hierarchy that I am obviously missing as the parser is not able to locate the
tag which contains the text that I require which in this case is "Prof. Zoltan Spakovszky".
Any help would be greatly appreciated.
public void getHomePageLinks()
{
String html = "http://ocw.mit.edu/courses/aeronautics-and-astronautics/16-050-thermal-energy-fall-2002/";
org.jsoup.nodes.Document doc = Jsoup.parse(html);
Elements bodies = doc.select("body");
for(Element body : bodies )
{
System.out.println(body.getAllElements());
}
}
the output is:
http://ocw.mit.edu/courses/aeronautics-and-astronautics/16-050-thermal-energy-fall-2002/
isn't it supposed to print out all the elements within the body tag in the document?
System.out.println(doc.body());
(see my answer below about getting thedoc
) – ollo Sep 11 '12 at 12:38