Python Forum

Full Version: XML question
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I'm just being curious Cool
When i program with an xml database, i can e.g. add a new "record",
and even add a new field to existing records in the database etc.(using elementTree)

It strikes me that during those operations you never say something like
"save" or "additem", or...
Only a the very end one does a tree.write(...),
and that (probably) overwrites the existing xml file.

My question: you start by reading the existing xml (db = ET.parse('members.xml')
and this keeps the whole thing in memory until the moment that you do tree.write?
I can imagine issues when the computer crashes.
So, is it best proctice to do multiple tree.write()s during operations?

thx,
Paul
what exactly xml database is? If you mean xml file, same apply for other file/formats that is processed in memory - i.e. it's up to you to assess cost/benefits - e.g. drag on performance of I/O operation on large file vs. risk of losing info.
OK, thx.

Paul