The XK8 is generally the better car (the S-Type has far worse electrics) but the XK8 transmission needs a rebuild at about 100K. You will also need to update the XK's timing chain assembly (~$750 at the dealer) as it had some severe problems until 03, and you want to make sure it doesn't have the Nikasil engine - 2000 was a transition year for that. The S-Type V6 (only engine mated to a manual) engine was just terrible full stop so that was even worse.
My recommendation: Get the XK8 and then *immediately* get an aftermarket warranty through 125K. The warranty will never be cheaper and aside from the aforementioned known issues they're great cars (note that many other cars in their class from Europe are much worse).