(abridged) Strongly star-forming galaxies of subsolar metallicities are typical of the high-redshift universe. Here we therefore provide accurate data for two low-z analogs, the well-known low-metallicity emission-line galaxies Haro 11 and ESO 338-IG 004. On the basis of Very Large Telescope/X-shooter spectroscopic observations in the wavelength range 3000-24000AA, we use standard direct methods to derive physical conditions and element abundances. Furthermore, we use X-shooter data together with Spitzer observations in the mid-infrared range to attempt to find hidden star formation. We derive interstellar oxygen abundances of 12 + log O/H = 8.33+/-0.01, 8.10+/-0.04, and 7.89+/-0.01 in the two HII regions B and C of Haro 11 and in ESO 338-IG 004, respectively. The observed fluxes of the hydrogen lines correspond to the theoretical recombination values after correction for extinction with a single value of the extinction coefficient C(Hbeta) across the entire wavelength range from the near-ultraviolet to the NIR and mid-infrared for each of the studied HII regions. Therefore there are no emission-line regions contributing to the line emission in the NIR range, which are hidden in the optical range. The agreement between the extinction-corrected and CLOUDY-predicted fluxes implies that a HII region model including only stellar photoionisation is able to account for the observed fluxes, in both the optical and NIR ranges. All observed spectral energy distributions (SEDs) can be reproduced quite well across the whole wavelength range by model SEDs except for Haro 11B, where there is a continuum flux excess at wavelengths >1.6mum. It is possible that one or more red supergiant stars are responsible for the NIR flux excess in Haro 11B. We find evidence of a luminous blue variable (LBV) star in Haro 11C.