Comparison of electronic structures of orthorhombic and hexagonal manganites studied by X-ray absorption spectroscopy