During the reign of Marquis Wen 魏文侯 (r. 424-387), he was appointed magistrate (ling 令) of Ye 鄴 (near modern Linzhang 臨漳, Hebei).
Story goes that at that time the River Zhang 漳 often inundated the surrounding land and that his floods could only be tamed when three shamanesses called Sanlao 三老, Tingchuan 廷椽 and Haozhang 豪長 were formally married to the "Earl of the River" 河伯, a deity symbolizing the Yellow River. A girl had furthermore to be annually offered to the river god as a "bride". The families of the girls were compensated with a sum of money.
When Ximen Bao was appointed magistrate, he immediately prohibited this superstitious custom and punished the three shamenesses. Instead, he organized the construction of twelve canals that helped amending the problem of inundation and at the same time provided irrigation for the fields.