In recent years, first principles density functional theory (DFT) has been developed to compute XPS binding energy. In particular, techniques based upon pseudopotentials have been developed to predict the core level shift (CLS) of the same element in different local environment, which opens the door for first-principles studies of large systems. Now that CLS is calculated as the difference of the total energy of the same system with different local excitations, systematic errors of approximate DFT, such as the bad gap underestimation with LDA or GGA functionals, cancel out, leading to a rather good agreement between theory and experiments. With continuous improvement in code efficiency and computing power, it is now possible to correlate CLS with a specific local atomic structure in the bulk or the surface of extended systems, which enables peak deconvolution and structure analysis in XPS studies.