I create XML documents by creating a full-blown in-memory DOM model and storing it to a file by using the IXMLDocument::save method. To format these documents, I use the trick with creating a text node consisting entirely of newline and tabs. This trick works well inside a node, but at the document level it fails. As a result, I get partially aligned documents like this:
<?xml version="1.0" encoding="UTF-8"?><!--Main Comment--><Root>
<InputFile>
<FileName>Part1</FileName>
<FileDirectory>D:\Document Folder\Testing</FileDirectory>
</InputFile>
. . . . .
</Root>
Is there any other trick to insert a newline before the main comment and before the root node? I prefer a solution that is limited to C++ DOM interfaces and does not involve external tools or libraries.