The x-ray absorption spectra of water and ice are calculated with a many-body approach for electron-hole excitations. The experimental features, including the small effects of temperature change in the liquid, are quantitatively reproduced from molecular configurations generated by abinitio molecular dynamics. The spectral difference between the solid and the liquid is due to two major short range order effects. One, due to breaking of hydrogen bonds, enhances the pre-edge intensity in the liquid. The other, due to a non-bonded molecular fraction in the first coordination shell, affects the main spectral edge in the conversion of ice to water. This effect may not involve hydrogen bond breaking as shown by experiment in high-density amorphous ice.PACS numbers: 36.20. Ng, 71.15.Pd, 32.10.Dk, 78.20.Ci The nature of the hydrogen bond (H-bond) network in water continues to be at the center of scientific debate [1]. A few years ago high-resolution x-ray absorption spectra (XAS) probed the local order of liquid and crystalline water phases, including the effect of temperature in the liquid [2]. These experiments stirred a storm of controversy because of their interpretation suggesting that a large fraction (>80%) of H-bonds are broken in the liquid [2]. This would imply an environment consisting primarily of chains and rings of H-bonds, in stark contrast with the conventional near-tetrahedral picture supported by diffraction [3] and other thermodynamic and spectroscopic data [4,5]. The broken H-bond fraction was estimated from the intensity of the pre-edge, which is prominent in the liquid and was believed to be absent in bulk ice. Subsequent x-ray Raman spectra, however, showed that the pre-edge feature is present, albeit with different intensity, not only in the liquid, but also in hexagonal (Ih), cubic (Ic), low-density amorphous (LDA) and highdensity amorphous (HDA) ice [6]. This experiment reported another interesting observation, namely that water and HDA ice have spectra with the main-edge more prominent than the post-edge, while the opposite behavior occurs in Ih, Ic, and LDA ice. This is puzzling given that both LDA and HDA ice are disordered structures with an insignificant fraction of broken H-bonds. Spectral calculations, based on electronic density-functional theory (DFT) and near-tetrahedral liquid models, correctly predicted the presence of three spectral features in ice and water and associated the enhancement of the pre-edge intensity to broken H-bonds [7,8,9,10]. However, the agreement with experiment was only semiquantitative and the calculations did not identify the cause of the significant changes in main-and post-edge spectra. These effects were generically attributed to disorder [8], but this does not explain why LDA and HDA ice show opposite behavior [6]. Finally, no attempt was made to discuss the effect of temperature in the liquid spectra, for which contrasting experimental data have been reported [2,11,12,13].In this paper we use liquid structures generated by ab-initio MD to compute x-ra...