The SAMEFIELD field function tells you whether two field references point to the same target.
SAMEFIELD returns a BOOLEAN value indicating whether two field references point to the same target. If they do, SAMEFIELD returns TRUE; otherwise SAMEFIELD returns FALSE.
DECLARE ref1 REFERENCE TO OutputRoot.XMLNS.Invoice.Purchases.Item[1]; MOVE ref1 NEXTSIBLING; SET Result = SAMEFIELD(ref1,OutputRoot.XMLNS.Invoice.Purchases.Item[2]);Result is TRUE.
See Creating dynamic field references for information about dynamic references.