X-ray absorption near-edge structure (XANES) and scanning photoelectron microscopy (SPEM) measurements have been performed for Zn1-xCoxO and Zn1-xMgxO to elucidate the effects of the doping of Co and Mg, which have very different electronegativities, on the electronic structures of ZnO nanorods. The intensities of O K-edge near-edge features in the XANES spectra of Zn1-xCoxO and Zn1-xMgxO nanorods are found to be lower than those of ZnO, which suggests that both Co and Mg substitutions of the Zn ions enhance the effective charge on the O ion. The valence-band SPEM measurements show that Mg doping does not increase the density of near-Fermi-level states, which implies that Mg doping will not improve field emission of ZnO nanorods. It is surprising to find that both Co and Mg substitutions of Zn increase the numbers of O 2p dominated valence-band states, despite that Co and Mg have larger and smaller electronegativities than that of Zn. (c) 2006 American Institute of Physics.