I want to upgrade windows xp to 7 or 8 but which one to buy?

It all depends on the hardware. Most older legacy CPUs will not have the required instruction sets needed to run Windows 7 or 8. If the upgrade advisor passes, then you should be good albeit the fact that you need to clean-install Windows in order to upgrade smoothly. If your hardware fails to meet the requirements for Windows 7, then you'll need to either purchase a new Windows 8.1 PC or tablet or install a Linux version compatible with your PC.