Magnetic X-ray absorption spectroscopy