cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
748
Views
5
Helpful
4
Replies

Need xpath help in uccx script

Aswin S
Level 1
Level 1

I have the below XML document in UCCX document management.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Numbers>
<DNIS>6022</DNIS>
<DNIS>6023</DNIS>
<DNIS>6024</DNIS>
<DNIS>6025</DNIS>
</Numbers>

When anyone call the UCCX application, script should compare the called number (CalledNumber Variable) with each DNIS row in the XML document and return true if CalledNumber and DNIS matches, if not return false if there are no matches found.

How can I achieve this? please help me on xpath to fetch the DNIS value one by one from XML so that I can compare inside my script.

1 Accepted Solution

Accepted Solutions

Have a look at this video, it should explain what you’d need to do. https://youtu.be/LUQI1JZclk0



Response Signature


View solution in original post

Can you specify an Xpath expression that you assemble on the fly using a variable to find the "record" you need inside an XML document? Sure you can. This clip looks at a subset of the entire 30 tutorial on the DrVoiP site and shows you how to create that Xpath expression by concatenating strings!
4 Replies 4

Have you tried to search for this in the community? With a minimum amount of effort you should be able to find examples of this, or at least as similar that would be usable enough for you to figure out how to do this, as it’s a type of topic that has come up on many occasions.



Response Signature


Yes Roger. I saw many examples, but using those examples, either returning Null value to my variable in Script or Java Exceptions error while running Reactive debug. I know this is a very simple and basic thing to identify xpath, but somewhere I am missing.

Have a look at this video, it should explain what you’d need to do. https://youtu.be/LUQI1JZclk0



Response Signature


Can you specify an Xpath expression that you assemble on the fly using a variable to find the "record" you need inside an XML document? Sure you can. This clip looks at a subset of the entire 30 tutorial on the DrVoiP site and shows you how to create that Xpath expression by concatenating strings!

Thanks Roger. Based on the video, I made some changes in my XML file and xpath, finally I got my required output.

 

Modified XML:

<Numbers>
<DNIS ID = "6022"><Number>6022</Number></DNIS>
<DNIS ID = "6023"><Number>6023</Number></DNIS>
<DNIS ID = "6024"><Number>6024</Number></DNIS>
<DNIS ID = "6025"><Number>6025</Number></DNIS>
</Numbers>

Working xpath:  /Numbers/DNIS[@ID=6022]/Number

Output is: 6022

Generic variables used in script are below:

1) String Variable, xpath1 = "//DNIS[@ID="

2) String Variable DNIS = CalledNumber (variable value)

CalledNumber value will be fetched by script get call contact info step (called number variable)

3) String Variable xpath2 = "]/Number"

Final xpath to be included in get xml document data step is xpath1 + DNIS + xpath2