I use Jsoup to select some code between <td></td>
tags. It looks like this:
Document doc = Jsoup.parse(response, "UTF-8");
Element elMotD = doc.select("td.info").first();
String motdText = elMotD.text();
My problem now is that jsoup selects the text like I want but it simply sorts out tags like <br>
which are important for my displaying in Android TextView later.
How can I do this that Jsoup doesn't miss the tags in between this text?
See here: http://jsoup.org/cookbook/extracting-data/attributes-text-html
Use the Element.html() method to get to the html including its inner html tags. You can also use Node.outerHtml() to the the html including the outer tags.
In your case:
Document doc = Jsoup.parse(response, "UTF-8");
Element elMotD = doc.select("td.info").first();
String motdHtml = elMotD.html();
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.