In situ X-ray photoelectron spectroscopy study of complex oxides under gas and vacuum environments