What is the best option for editing XML files in Python that preserve the original formatting of the file? -
i want able edit existing xml config files via python while preserving formatting of file , comments in them still human readable.
i updating existing xml elements , changing values adding new xml elements file.
available xml parsers such elementtree , lxml great ways edit xml files loose original formatting(when adding new elements file) , comments in file.
using regular expressions seems option know not recommended xml.
so i'm looking along lines of pythonic xml file editor. best way go this? thanks.
i recommend parse xml document using sax parser, gives great flexibility make changes , write document was.
take @ xml.sax
modules (see python's documentation).
Comments
Post a Comment