in reply to Replacing everything in between using s///;

Don't be using regex for this. Use a tree-processing language, like xsh:
#!/usr/bin/env xsh $file = open "myfile.xml"; insert comment "BOX1" replace //span[id="box1"]; save;

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.