The 8800 GTS is better, and it isn't especially close despite what the numbering suggests.
Nvidia's model numbers don't run in strict performance order across generations. The 9400 GT was a budget card, while the 8800 GTS was a high-end part in its day, and that gap in intended market shows in the benchmarks.
If you're choosing between two used cards, the 8800 GTS is the pick. Just check that your power supply and case can handle it, since the older high-end cards run hot and draw considerably more.