Construct new XPathGenerator with a flag to tell it to always specify child index positions in the resulting xpath expression. By default the XPathGenerator only generates child index positions if the child is not uniquely named in the collection of children. For example, you might get the xpath expression: