Saturday, 10 December 2016

java - Extract innerHtml out of body tag using jsoup



I am parsing html using jsoup and want to extract innerHtml inside of body tag



so far I tried and use document.body.childern().outerHtml; but its giving only html element and skipping floating text(not wrapped within any html tag) inside of body




private String getBodyTag(final Document document) {
return document.body().children().outerHtml();
}


Input:











questions to improve formatting and clarity.

Guided Mode


some sample raw/floating text





Expected:



questions to improve formatting and clarity.

Guided Mode


some sample raw/floating text


Actual:




questions to improve formatting and clarity.

Guided Mode



Answer



Please use this:



private String getBodyTag(final Document document) {
return document.body().html();
}


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...