This script contains two structs: XmlDocument and XmlNode, which provide a strctured way to read and write XML files. Its a simple script that should be self-explanatory and easy to customize. You can download the example script for usage.
There is already a good XML utility script, which I recommend if you don't need to customize heavily.
That script uses the DotNet library to read/write XML, which was supported as of version 9. If you have an older version of Max, don't want to use the DotNet library, or want something that you can customize completely, then you can use my script instead :)