N-doped carbon nanotubes (NCNTs) were synthesized and their electronic structures have been explored by X-ray absorption near-edge structure (XANES) spectroscopy. With a surface sensitive mode, XANES confirms the N-doping in NCNTs. However, with a more bulk sensitive detection mode of XANES, large amount of gaseous N2 have been found to be sealed in NCNTs, even in a high vacuum environment. The encapsulation of the ferrocene residues in carbon nanotubes had been revealed by scanning transmission X-ray microscopy (STXM), which may help for the N2 sealing. The results suggest that the easily sealed gas should be taken into consideration for CNT-based applications.