Editing xml files thru scripting

Is it possible to edit xml files thru scripting? Id like to be able to modify these 2 files on the fly. Im not sure if it would be better to store what I want in the database then generate a new file, or if it is possible to open the file and append or edit the existing file.

This is my first foray into this type of thing so I am not even sure where to start.

for instance, on the contacts.config file, I would like to be able to add or remove lines. again, I am not sure if it wouldnt be better to store this in the database and then write a new file if that is possible.

On the emailgroups it is a little more complicated. I would need the ability to not only add or delete rows, I would need the ability to add/edit information in each row. for instance:

test~;\tom thumb\emailWork~Always~;\mickey mouse\emailWork~Always~;

may need to be changed to

test~;\tom thumb\emailWork~Always~;\mickey mouse\emailWork~Always~;\kate upton\emailWork~Always~;

So can this be done and what would be the best way to try and tackle it?

This python page will give you a good introduction to the open() and write() functions within python:


Once you read in the file, you’ll find the line you want to replace, do some string formatting, and then write that data back out to the file.