X-ray Absorption Spectroscopy Calculations From First Principles