When the high-energy electrons hit the sample, they can eject inner-shell electrons from the atoms in the material. This generates an electron hole that is then filled by an electron from a higher energy level. The difference in energy between these two levels results in the emission of X-rays. The energy of these X-rays is characteristic of the elements from which they originated, allowing for the identification of the elemental composition of the sample.