There are three endings on X5, one as Zero and two as X. You need to defeat Sigma with both characters, you can get at least two of them on a single save.
Ending #1, Zero:
Just finish the game as Zero.
Endings #2/3, X:
Which ending you get depends on if you destroyed Eurasia before the 18-hour deadline and before you go into the Sigma stages. If you don't, Zero might become infected.
If you fail to destroy Eurasia with the shuttle and Enigma, you'll get the bad ending, but Zero won't get infected.