Ti and Al K-edge x-ray absorption spectroscopy is used to investigate the electronic structure of Ti1-xAlxN thin films deposited by reactive magnetron sputtering. The experimental near edge spectra of TiN and AlN are interpreted in the light of unoccupied density of state band structure calculations. The comparison of the structural parameters derived from x-ray absorption fine structure and x-ray diffraction reveals segregation between Al-rich and Ti-rich domains within the Ti1-xAlxN films. Whereas x-ray diffraction probes only the crystallized domains, the structural information derived from extended x-ray absorption fine structure analysis turns on both crystalline and grain boundaries. The results are discussed by considering the damage behavior of the films depending on the composition.