XPath List Construct

I am unable to use a variable for denoting an index in an XML list. For example, I can use //PurchaseNo[2] to denote the 2nd purchase number element from my xml document. However, using //PurchaseNo[i] where i is a loop counter return an error ora-30625?

Can anyone help?

Also,
Is there a way to execute a PL/SQL command that has been put into a string variable?