I am completely new to jsoup as of a few hours ago, but i have been reading some beginner tutorials and questions on here but i haven't been able to solve my issue. I have mostly just been guessing at the right combination of css tags but no luck whatsoever.
The element that i'm trying to access is the 'id' tag of this line, i want to store it in a string variable to be more precise.
<div class="inElm" id="elm11329383">
It is the first of many "inElm" class objects in the document, but i just need the first one's 'id' value. I would post a picture but i'm a noob, here's what i thought would work...
69 Element link = doc.select("div#inElm").first();
70 String idTag = link.attr("id");
71 text.setText(idTag);
Am I close, or do i need to worry about the hierarchy of the document in order to find it? any advice is much appreciated!
here's the whole private Async class:
private class jsouptest extends AsyncTask<Object, Object, Object>{
@Override
protected Object doInBackground(Object... arg0) {
Document doc = null;
String url = "http://www.pinkbike.com/photo/podlist/";
try {
doc = Jsoup.connect(url)
.userAgent("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0")
.referrer("http://www.google.com")
.get();
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (HttpStatusException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Element link = doc.select("div.inElm").first();
String idTag = link.attr("id");
text.setText(idTag);
return null;
}
}