On Sep 27, 6:42 pm, "Mike Schilling" <mscottschill...@hotmail.com>
wrote:
You could use XSLT to do the serialization (using an identity
transformation) and tell that to omit the XML declaration.
I tried changing my code to use the TrAX transformer since it has
a property to omit the xml declaration:
Transformer transformer = TransformerFactory.newInstance
().newTransformer();
transformer.setOutputProperty("indent","yes");
transformer.setOutputProperty("omit-xml-declaration","yes");
DOMSource source = new DOMSource(document);
Result result = new StreamResult(output);
transformer.transform (source, result);
But, now it outputs the XML with one tag per line. The lines are
not
indented
to show nesting even though I set indent to yes. Here is a sample:
<Tag1>
<Tag2>A</Tag2>
<Tag3>B</Tag3>
</Tag1>
I want it to appear as:
<Tag1>
<Tag2>A</Tag2>
<Tag3>B</Tag3>
</Tag1>
Any ideas how to make that happen?
Sorry, I don't know.