To avoid subtle incompatibilities between Darwin and Linux (such as the different handling on <?xml ...?> prologues), we could write our own XMLDocument to String conversion or just roll our own XML element types.
This would also give us fine control over formatting without having to patch the string afterwards (which is a lot slower).