The scattering of moderately high-energy x rays from electrons in magnetic solids is analyzed. We show that (a) the incoherent Compton scattering of polarized x rays can be used to determine the spin-dependent momentum distribution function of electrons in ferromagnetic materials, and (b) the coherent Bragg scattering of unpolarized x rays can be used to determine the magnetic structure of antiferromagnetic solids below their transition temperature.