There's many way to do that.
What you request should be something like: - open file - parse file using minidom as the format is xml - change it - save it
But depending of the frequency of your changes, it's not a good idea (cpu consuming).
A better way would be to load/parse/change, but then instead of saving it, you could directly send your new timeline to the motion module using motion.angleInterpolationBezier.
Other ways are to export your timeline to python using the "Export motion to clipboard" then to use pure python to modify your timeline like arrays, save it, ...