X-ray absorption spectroscopy (XAS) is a powerful experimental tool to probe the local structure in materials with the core hole excitations. Here, the oxygen K-edge XAS spectra of the NaCl solution and pure water are computed by using a recently developed GW-Bethe-Salpeter equation approach, based on configurations modeled by path-integral molecular dynamics with the deep-learning technique. The neural network is trained on abinitio data obtained with strongly constrained and appropriately normed density functional theory. The observed changes in the XAS features of the NaCl solution, compared to those of pure water, are in good agreement between experimental and theoretical results. We provided detailed explanations for these spectral changes that occur when NaCl is solvated in pure water. Specifically, the presence of solvating ion pairs leads to localization of electron-hole excitons. Our theoretical XAS results support the theory that the effects of the solvating ions on the H-bond network are mainly confined within the first hydration shell of ions, however beyond the shell the arrangement of water molecules remains to be comparable to that observed in pure water.