RNiO3 perovskites (R=Pr,Nd): Nickel valence and the metal-insulator transition investigated by x-ray-absorption spectroscopy.