In the development of the eXensible Markup Language (XML), effective query of XML documents was a hot issue. It was very important to quickly and effectively judge whether the two elements had relationship of ancestor/descendant. The existing prime number labeling method needed a number of primes and some big primes, therefore, an improved prime number labeling method-most brothers prime was proposed. There was no need to use new prime numbers for each node in this method. Both the theoretical analysis and the experiments showed that the prime numbers and the biggest prime were reduced in the most brothers prime method. So, this improved method facilitated the query process.