Magnetic reconnection as the origin of X-ray jets and Hα surges on the Sun