I want to be able to edit existing XML config files via Python while preserving the formatting of the file and the comments in them so that its still human readable.
I will be updating existing XML elements and changing values as well as adding new XML elements to the file.
Available XML parsers such as ElementTree and lxml are great ways to edit XML files but you loose the original formatting(when adding new elements to the file) and comments that were in the file.
Using Regular expressions seems to be an option but I know that this is not recommended with XML.
So I'm looking for something along the lines of a Pythonic XML file editor. What is the best way to go about this? Thanks.