jSoup extract Text out of DIV tag to String
android, java, jsoup, text
Solution
Use the below
Elements text = document.select("div");
String desc = text.text();
Log.i(".........",+desc);
The log after trying at my end
01-31 04:45:15.272: I/.........(1233): I want to get this Text
Edit:
You can use
Elements text = document.select("div[class=textclass]");
or using id
Elements text = document.select("div[id=textid]");
or
Elements text = document.select("div[itemprop=itemtext]");
Problem
I want to extract some Text out of a website and store in String. ``` <div class="textclass" id="textid" itemprop="itemtext">I want to get this Text</div> ``` What goes into the question marks? ``` protected Void doInBackground(Void... params) { try { Document document = Jsoup.connect(url).get(); Elements text = document.select("???"); desc = text.attr("???"); } catch (IOException e) { e.printStackTrace(); } return null; } ```