For example I have
<html lang="en"> ...... web page </html>
I want to extract the string "en" with Jsoup.
I tried with selector and attribute without success.
Document htmlDoc = Jsoup.parse(html);
Element taglang = htmlDoc.select("html").first();
System.out.println(taglang.text());
Looks like you want to get value of lang
attribute . In that case you can use attr("nameOfAttribute")
like
System.out.println(taglang.attr("lang"));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.