Avatar

Correct answer by
Level 8

Your xpath doesn't match your XML - you are missing the root node in your xpath expression:

Expression: /process_data/myXML/records/record[1]/email

should be:

           /process_data/myXML/root/records/record[1]/email

When you build your loop there is one other thing to be careful of.  If you evaluate an xpath variable inside of another xpath expression, it gets inserted as a string.  This happens even if the variable is an integer.  For example:  If I have an integer variable counter which is set to 3 and evaluate:

     /process_data/myXML/root/records/record[/process_data/@counter]/email    The xpath expression will insert "3" (a string) and not an integer as you would expect.  The result will not be the third node. This can be a source of frustration and its hard to debug.

Instead, use the number function inside the expression:

  /process_data/myXML/root/records/record[number(/process_data/@counter)]/email

I've attached a sample process that shows this.

View solution in original post