  In this work we study several $\Xi_c$ and $\Xi_b$ states dynamically
generated from the meson-baryon interaction in coupled channels, using an
extension of the local hidden gauge approach in the Bethe-Salpeter equation.
These molecular states appear as poles of the scattering amplitudes, and
several of them can be identified with the experimentally observed $\Xi_c$
states, including the $\Xi_c(2790)$, $\Xi_c(2930)$, $\Xi_c(2970)$,
$\Xi_c(3055)$ and $\Xi_c(3080)$. Also, for the recently reported $\Xi_b(6227)$
state, we find two poles with masses and widths remarkably close to the
experimental data, for both the $J^P=1/2^-$ and $J^P=3/2^-$ sectors.
