If the cd is labelled "Operating System" and doesn't say recovery or restore, then it is just a regular XP cd and yes you can use that with either. Don't use the Drivers/Applications/Updates CD's from the notebook on the desktop though. You'll need to download the drivers specific to your desktop's hardware from HP's Support Site.
If your desktop didn't come with CD's though, you may have a recovery partition - TRY THIS FIRST, it's much better than searching for drivers. In the initial boot screen, at the bottom there are usually options. F1 for Setup, F10 for Recovery options, ESC for boot menu. I'm pretty sure it's F10 for HP though, when you get into it you want to choose Destructive - that will format your drive and install all OS files and software as it was from the factory.
Good Luck
If your desktop didn't come with CD's though, you may have a recovery partition - TRY THIS FIRST, it's much better than searching for drivers. In the initial boot screen, at the bottom there are usually options. F1 for Setup, F10 for Recovery options, ESC for boot menu. I'm pretty sure it's F10 for HP though, when you get into it you want to choose Destructive - that will format your drive and install all OS files and software as it was from the factory.
Good Luck