I have followed the example in this thread but I am still having problems in using a variable (string) in the Xpath command:
This is the contents of my xml file:
<?xml version="1.0" encoding="ISO-8859-1"?>
(The file continues with many more dates and redirect numbers).
My script runs by first building todays date which is stored in the string variable todaysDate. It is stored in this format 5/1/2010 etc.
My Get XML Document Data step has the Xpath statement as follows:
This works fine. But when I want to substitute the hard coded date value with a variable I have problems. The link above suggests that the variable should be enclosed in quotes so in my case this would be:
The problem is that when I try to enter this, I get the message "Unable to parse expression; Couldn't repair and continue parsing on token #ID 'todaysDate' (line: 1, col: 49)
I have tried a few other combinations but no luck.
Can someone help?
You need to use single quotes to qualify the String value in the predicate. Example:
"/descendant::SBS_AM_agent_root/child::am[date='" + todaysDate + "']/child::redirect/"
Also, the CCX documentation does a bad job of explaining Xpath. This could just as easily be:
"/SBS_AM_agent_root/am[date='" + todaysDate + "']/redirect"
You may want to take the W3Schools Xpath tutorials for a good starter.