Effects of multiple scattering in the x-ray absorption spectra of molecules and solids