Edit a file and save the changes

I have an xml file that gets created as a part of daily build. I have to modify some lines in this file, uncomment some lines, comment some line, add 2 new lines in the file every time.
Is there an easier automated way to do this using perl, bash, or sh. I would appreciate it if someone can point me to a solution so I do not have to do this manually everyday.

SD

You need to specify what exactly you want to do.