Pretty print XML in java 8
In reply to Espinosa’s comment, here is a solution when “the original xml is not already (partially) indented or contain new lines“. Background Excerpt from the article (see References below) inspiring this solution: Based on the DOM specification, whitespaces outside the tags are perfectly valid and they are properly preserved. To remove them, we can … Read more