Skip to content Skip to sidebar Skip to footer

Getting Attribute Value From Div Tag Through JSoup

I have a Div tag as below
5 days 07:14:41
How do i get the value of

Solution 1:

Element div = doc.getElementById("eventTTL");
String attr = div.attr("eventTTL");
System.out.println(attr);

More info at: https://jsoup.org/cookbook/extracting-data/attributes-text-html


Solution 2:

In case if your DIV has no Id:

Element div = doc.select("div[eventTTL]").first();
System.out.println(div.attr("eventTTL"));

Post a Comment for "Getting Attribute Value From Div Tag Through JSoup"