In X-ray photoelectron spectroscopy (XPS) X-rays are used to knock electrons out of atoms in a sample. An electron energy analyzer then captures the ejected electrons and a plot of the number of electrons per energy increment is obtained (a spectrum). Each element has a characteristic spectrum. For mixture of elements the result is approximately the sum of the individual element's spectra. Since the mean free path of electrons in a solid is only a few atomic layers the technique is mostly surface-sensitive.
Here is an example of an simple XPS spectrum (in French):
In the previous spectrum the number of electrons is plotted as a function of binding energy. The 284.6 eV electrons seen here are easily identified as the so-called K-shell electrons of carbon and the 532.5 eV line represents the K-shell electrons of oxygen. The equation representing the process is the following:
Binding energy = x-ray energy - kinetic energy - work function
We can think of the electron in the sample as absorbing the energy of an x-ray. The electron then uses part of that energy to free itself from its nucleus, then it looses energy to overcome the work function of the sample, (a sort of surface barrier for the electron), and finally emerges from the sample with the remaining energy, which is in the form of kinetic energy. By measuring this kinetic energy we can deduce what the binding energy must have been. Since the energy levels of electrons in atoms are precisely defined and characteristic for the various elements we can consequently identify the atom from which the detected electron originated. This is the simplest case scenario and other processes may also be observed such as the Auger process in which the electron kinetic energy is actually independent of the incident x-ray energy. The Auger process is described furtheron this page and a short series of tutorials on XPS can be found here on a manufacturer's web site.