X-ray absorption near-edge fine structure (XANES) spectroscopy from N K-edge measurement was employed to examine the crystal structure of metallorganic vapor phase epitaxy (MOVPE) grown Mg-doped GaN (GaN:Mg) films. The result showed that Mg doping induced crystal stacking faults to occur at the film surface causing a fraction of hexagonal phase to transform into cubic phase. As a consequence of this, XANES spectra of the films were found to vary with the dopant concentration and to lose pure hexagonal character when examined with the incident angle θ of the X-ray beam. Spectral characteristic variation between the two phases allows us to estimate the phase composition of the samples. The trend of increasing cubic phase component in dopant concentration is consistent with the observed Normaski optical micrograph.