Electron- and hole-doping effects on the electronic structure of manganite studied by x-ray absorption spectroscopy