This is currently vexing me.
Jsoup is including an extra line break in the returned string if the string includes <br />
eg.
String html ="TEST<br />TEST";
Jsoup.clean(html, org.jsoup.safety.Whitelist.basic());
returns
TEST\n<br />TEST
Any advice on how to avoid the inclusion of the troublesome \n?
Have you tried
.text();or.ownText();from theElementsclass?If each
elementreturned< p>Hello< b> there< /b> now!< /p>text();would returnHello there now!ownText();would returnHello now!Just to make it easier to understand: The
.text();will return the whole text within the tag you got. TheownText();method will return the text from the tag itself, and not the text from its children.About the query in
doc.select("query");, you can search here for any pattern you want.