Originally published November 17, 2008.
Information provided in this post may be out of date.
Getting nicely indented XML from XOM as a String is not intuitive. One might reasonably expect to try
document.toXML() only to find the output lacking indentation.
Here’s how I used XOM’s Serializer and Java’s
ByteArrayOutputStream to produce pretty XML.