in reply to xml::twig pretty_print

You can get the same formating as in the original file by using the keep_spaces => 1 option when you create the twig. Note that this will create #PCDATA (text) elements that contain the whitespaces in your tree.

Update: I updated the FAQ with this question.