I've done it before, so the general answer is yes. Important questions are
1) Are there windows 7 drivers for all of your hardware? if the machine is old enough, there may not be drivers and the machine may not run windows 7.
1.5) Does the hardware support 64-bit OSes? Back in the days of XP, plenty of 32-bit machines were manufactured. You have not provided information on that make and model of the machine, and what processor is in it.
2) Make a complete image backup of your system drive to an external drive before trying this. Test that it is valid. If something goes wrong, you will be able to restore the previous state of your system.
3) Windows 7 will require its own partition. You will have to allocate a new...