So I need to write a script that will look at a bunch of larger (3 MB'ish) XML files, parse through them, and then "hide" certain elements via XML comments if a certain flag is set. As a "bonus", I need to be able to revert the commenting changes later on. I'm somewhat at a loss on what would be the best approach to take here. I was thinking about doing some PHP stuff, running each file as a thread, but I can't think of a way to actually "comment" out the element, let alone how to "uncomment" them. Other option I've thought about was putting it all on a linux box and scripting it, but that could be ugly if I had to actually grep through all the files or something. Also might look into Ruby, as I heard they have some decent XML support. Anyone done/tried to do anything like this? I need something that would be relatively do to the size and amount of the files, but figured threading it would likely help immensely. I'm more stuck on how to actually "introduce" comments into a file, and then remove them.