I have an XML document that I would like to update after it already contains data.
I thought about opening the XML file in "a" (append) mode. The problem is that the new data will be written after the root closing tag.
How can I delete the last line of a file, then start writing data from that point, and then close the root tag?
Of course I could read the whole file and do some string manipulations, but I don't think that's the best idea..
To make this process more robust, you could consider using the SAX parser (that way  you don't have to hold the whole file in memory), read & write till the end of tree and then start appending.
How to update/modify an XML file in python?