The present invention relates to a method of inhibiting Helicobacter pylori, principally using a compound A or a compound B for feedback inhibition of 3-dehydroquinate dehydratase in the shikimate pathway to inhibit Helicobacter pylori. The said compound A is one of the compounds as follows: benzoic acid, benzoic acid derivative, phenylacetic acid, phenylacetic acid derivative, trans-cinnaminic acid, 1,4-cyclohexanedicarboxylic acid, 4-indophenylboronic acid, phthalic acid and 3,4-dimethoxybenzyl alcohol. The said compound B is precursor of benzoic acid, benzoic acid derivative, phenylacetic acid or phenylacetic acid derivative generated by β-oxidation of fatty acids.