Spectrophotometry of six high-excitation compact H II regions in the Magellanic Clouds