I have ubuntu12.04 and win7 on my netbook. now i'm going to install winXP instead of 7 but I have no optical drive to use ubuntu liveCD and I know if I do this, my grub will go.. the only way is by using my flash but how??..
You can use a software named Super Grub2 Disk. From there you could have a grub entry then you can update-grub and install it again.
You can also do it via CLI http://www.gnu.org/software/grub/manual/html_node/Making-a-GRUB-bootable-CD_002dROM.html
you can make an iso for your grub and burn it into cd then after installing your windows you can restore the grub but you need to update it since entries will be changed. The rest is easy if you have prob you can find your answer here.