To format a hard disk and install XP to factory settings there are three options
1: Restore from a hidden partition on your hard disk. This feature is common with newer computers but is not available to you. I asked for the computer's details to find what your options are.
2: Restore from recovery disks supplied by the manufacturer. For this you must have the disks. Have a look at this link
to see what HP says about the subject. This may be your cheapest and easiest solutions because the disks include all the basic drivers required by the computer.
3: Buy a retail or OEM installation CD. Retail is the most expensive but most flexible option. You have to get the computer's drivers but there are benefits regarding repair installations and installations on upgraded or new hardware (Microsoft's permission must be asked. and is given, to activate such installations). OEM is cheaper but more limited. If you wish to understand the differences please read this
Repair installation is not what you look for. The repair leaves your documents and filed intact, bugs, viruses and other malware included. You look for a complete wipe of your disk. Besides, XP repair very often fails and you can end up with more problems then you started with.