Output JSoup without added spaces and line breaks around the elements Output JSoup without added spaces and line breaks around the elements xml xml

Output JSoup without added spaces and line breaks around the elements


With some help from Aleksandr M I solved it in the following way:

doc.outputSettings().indentAmount(0).prettyPrint(false);

A little less nice, but this also seemed to do the trick:

htmlWriter.write(doc.toString().replaceAll(">\\s+",">").replaceAll("\\s+<","<"));


Try this:

doc = Jsoup.parse(is, "UTF-8", "", Parser.xmlParser());doc.outputSettings().escapeMode(Entities.EscapeMode.xhtml);....

Hope this helps