Understanding the formation of gold and iron based nanomaterials using X-ray absorption spectroscopy