Photoemission and X-ray absorption studies of magnetic materials