X-ray photoionized plasmas in space and in the laboratory