refactor XML comparison of elements