In this paper we investigate the attitude measurement based on X-ray pulsar scanner, the detection efficiency of X-ray pulsar scanner is described by the transfer function. We present the attitude measurement models of X-ray pulsar scanner, which is fit by Genetic Algorithms. The attitude angles of the spacecraft are gained by numerical simulation techniques. Firstly, the coordinate systems and the conversion matrices of the attitude measurement based on X-ray pulsars scanner are presented. The structure of the X-ray pulsar scanner is designed. The differences between X-ray pulsar scanner and the classic scanner are analyzed, and the advantages of X-ray pulsar scanner are discussed. The collimation process of X-ray pulsar collimator is analyzed, the transfer function of collimator is given. The detection efficiency of X-ray pulsar scanner is described accurately by the model of transfer function. The geometric projection angle of the pulsar in the instrument coordinate system is defined which are used to describe function of collimator. Secondly, by using the transfer function of collimator and spacecraft attitude dynamic equations, the mathematical model between the geometric projection angle and the spacecraft attitude angle is established. The described equation of X-ray photon curve is deduced by using the transfer function and the mathematical model. The photon curve recorded by scanner is fitted by the equation. The attitude measurement model based on X-ray pulsar scanner is obtained. This model is discrete mathematical model of optimization. The Genetic Algorithms is adapted for the discrete mathematical model of optimization. The model is optimized by Genetic Algorithms, and the unit vectors of pulsars in the instrument coordinate system are obtained. The spacecraft attitude angles are calculated finally by the double-vector method. Finally, the above models are verified by the numerical simulation. The feasibility and effectiveness of the attitude measurement based on X-ray pulsar scanner are shown by the simulation results. The X-ray pulsar signal is strong, and it is apt to be detected by small devices. Therefore, the spacecraft payload is reduced. The natural X-ray signal is not susceptible to man-made disturbance. The safety and autonomy of the spacecraft are enhanced. This paper provides a new technique for spacecraft attitude measurement.