String trim = result.trim();
Document dom = getXhtmlDOMFor(new StringReader(trim));
Element firstChild = (Element) dom.getFirstChild();
for (int i = 0; i < firstChild.getChildren().size(); i++) {
Node next = firstChild.getChildren().get(i);
if (i == 0 && firstChild.getChildren().size() == 1) {
if (next instanceof org.thymeleaf.dom.Text) {
org.thymeleaf.dom.Text nextText = (org.thymeleaf.dom.Text) next;
nextText.setContent(nextText.getContent().trim());
}