Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
csg
Community Member

UCCX 7.0 - Xpath (syntax problem)

Hello all,

I have followed the example in this thread but I am still having problems in using a variable (string) in the Xpath command:

https://supportforums.cisco.com/message/1323750#1323750

This is the contents of my xml file:

<?xml version="1.0" encoding="ISO-8859-1"?>

<SBS_AM_agent_root>

     <am>

          <date>5/1/2010</date>

          <redirect>5555</redirect>

     </am>

     <am>

          <date>6/1/2010</date>

          <redirect>5566</redirect>

     </am>

(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:

"/descendant::SBS_AM_agent_root/child::am[date='5/1/2010']/child::redirect/"

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:

"/descendant::SBS_AM_agent_root/child::am[date="todaysDate"]/child::redirect/"

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?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
VIP Super Bronze

Re: UCCX 7.0 - Xpath (syntax problem)

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.

4 REPLIES
Community Member

Re: UCCX 7.0 - Xpath (syntax problem)

Hi,

Please try this and see if this helps

"/descendant::SBS_AM_agent_root/child::am[date=" + todaysDate + "]/child::redirect/"

csg
Community Member

Re: UCCX 7.0 - Xpath (syntax problem)

When I try that I can enter the command but on debugging the script when it gets to this step the following error is displayed:

"Expected ], but found:1; nested exception is: javax.xml.transform.TransformerException; Expected ], but found :1"

Any more ideas?

Thanks

VIP Super Bronze

Re: UCCX 7.0 - Xpath (syntax problem)

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.

csg
Community Member

Re: UCCX 7.0 - Xpath (syntax problem)

Thanks for the help, that worked out perfectly.

It takes a bit of hair pulling to figure out how xpath works but I agree with your earlier posts in that it can be very useful.

986
Views
5
Helpful
4
Replies
CreatePlease to create content