refine xpath generating code.