X-ray spectroscopy works by bombarding a sample with x-rays, which causes the atoms in the sample to emit secondary x-rays. These emitted x-rays are characteristic of the elements present in the sample. By measuring the energy and intensity of the emitted x-rays, scientists can determine the elemental composition and concentration of the elements.