Spectroscopy with soft X-rays was used to develop new materials and novel designs for solar cells and artificial photosynthesis. In order to go beyond the widely-used trial-and-error approach of gradually improving a particular design, we started from the most general layout of a solar cell (or a photo-electrochemical device) and asked which classes of materials are promising for best performance. For example, the most general design of a solar cell consists of a light absorber, an electron donor, and an electron acceptor. These are characterized by four energy levels, which were measured by a combination of spectroscopic X-ray techniques. Tuning synchrotron radiation to the absorption edges of specific elements provided element- and bond-selectivity. The spectroscopic results were complemented by state-of-the-art calculations of the electronic states. These helped explaining the observed energy levels and the orbitals associated with them. The calculations were extended to a large class of materials (for example thousands of porphyrin dye complexes) in order to survey trends in the energy level structure. A few highlights serve as examples: 1) Organic molecules combining absorber, donor, and acceptor with atomic precision. 2) Exploration of highly p-doped diamond films as inert, transparent electron donors. 3) Surface-sensitive characterization of nanorod arrays used as photoanodes in water splitting. 4) Computational design of molecular complexes for efficient solar cells using two photons.