  In the past two decades, various classes of topological materials have been
discovered, spanning topological insulators, semimetals, and metals. While the
observation and understanding of the topology of a material has been a primary
focus so far, the precise and easy control of topology in a single material
remains largely unexplored. Here, we demonstrate full experimental control over
the topological Dirac nodal loop in the square-net material
LaSb$_\mathrm{x}$Te$_\mathrm{2-x}$ by chemical substitution and electron
doping. Using angle-resolved photoemission spectroscopy (ARPES), we show that
changing the antimony concentration x from 0.9 to 1.0 in the bulk opens a gap
as large as 400 meV in the nodal loop. Our symmetry analysis based on
single-crystal X-ray diffraction and a minimal tight binding model establishes
that the breaking of \textit{n} glide symmetry in the square-net layer is
responsible for the opening of the gap. Remarkably, we can also realize this
topological phase transition \textit{in situ} on the surface of
LaSb$_\mathrm{x}$Te$_\mathrm{2-x}$ by chemical gating using potassium
deposition, which enables the reversible switching of the topology from gapped
to gapless nodal loop. The underlying control parameter for the structural and
topological transition in the bulk and on the surface is the electron
concentration. It opens a pathway towards applications in devices based on
switching topology by electrostatic gating.
