This needs more tests, for different msxml object versions, and for different input document. It's possible that get_xml() returns original document, so test loading non trivial document is necessary.
I remember looking at this some time ago, not for this specific report but in general, and my conclusion was that the only way to generate matching document is to duplicate node dumping in our code.