  The radiation from stars and active galactic nuclei (AGN) creates
photodissociation regions (PDRs) and X-ray dominated regions (XDRs), where the
chemistry or heating are dominated by far-ultraviolet (FUV) radiation or X-ray
radiation, respectively. PDRs include a wide range of environments from the
diffuse interstellar medium to dense star-forming regions. XDRs are found in
the center of galaxies hosting AGN, in protostellar disks, and in the vicinity
of X-ray binaries. In this review, we describe the dominant thermal, chemical,
and radiation transfer processes in PDRs and XDRs, as well as a brief
description of models and their use to analyze observations. We then present
recent results from Milky Way, nearby extragalactic, and high-redshift
observations. Several important results are:
  $\bullet$ Velocity resolved PDR lines reveal the kinematics of the neutral
atomic gas and provide constraints on the stellar feedback process. Their
interpretation is, however, in dispute as observations suggest a prominent role
for stellar winds while they are much less important in theoretical models.
  $\bullet$ A significant fraction of molecular mass resides in CO-dark gas
especially in low-metallicity/highly irradiated environments.
  $\bullet$ The CO ladder and CI/CII ratios can determine if FUV or X-rays
dominate the ISM heating of extragalactic sources.
  $\bullet$ With ALMA, PDR and XDR tracers are now routinely detected on
galactic scales over cosmic time. This makes it possible to link the star
formation history of the Universe to the evolution of the physical and chemical
properties of the gas.
