Using variables in Xpath
For an xml data source, if you want to extract a book based on the book id, you can do so by creating a number global variable called $bookid and referring it in the xpath in the sample code below. The variable $bookid can also be manipulated in the script.
<library>
<book1>
<title>The Great Gatsby</title>
<author>F. Scott Fitzgerald</author>
</book1>
<book2>
<title>To Kill a Mockingbird</title>
<author>Harper Lee</author>
</book2>
<book3>
<title>1984</title>
<author>George Orwell</author>
</book3>
</library>
Repeating sections
Variables and scripts can be used with repeating sections along with conditions. Each content control in a repeating section can be subject to different conditions or calculations. This allows different use cases such as accumulating a running sum and display the total in the end. Or specify certain conditions, so if the xpath value match those condition you can display a different value or hide the value or use a different font for example.
Local variables
You can also define a local variable inside the Scripting tab. This local Variable is just a helper variable used in the scope of the script but lost afterwards. Local variables must be declared with the dataType $VariableName; otherwise an error is displayed. The local variable can be declared and it’s value assigned later but just be careful not to use a local variable without assigning a value as there is no syntax check currently.