I'm going to assume you're already running XP on the hard drive you want to install to, and you have an empty 40 gig partition on that hard drive as well. Is this correct?
What you want to do is pop in the Ubuntu CD and boot from it. It's a live CD, so you can run it and browse around the OS if you like. Once you're ready to install, there's an Install icon on the desktop. Double click it and it will begin to take you through the steps of installation.
It will come to a point where it will ask you what partition to install it on. It will have an option that says something like "Guided - Use Largest Contiguous Free Space". This is the option you will want. It will take that free space you have and install the OS on it.
After that, everything is self explanatory. It will install the Grub boot loader on it's own and will automatically setup your dual boot so you should have Ubuntu, Ubuntu (recovery mode), memtest86, and Windows XP in your OS choices menu.