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

UCCX Script XML Select equivalent

Assume the following XML document exists:

<Technician>

      <ID>1234</ID>

           <CellPhone>5039991234</CellPhone>

           <HomePhone>5039992345</HomePhone>

     <ID>2345</ID>

           <CellPhone>4155551212</CellPhone>

           <HomePhone>4151234445</HomePhone>

     <ID>5678</ID>

           <CellPhone>6125431234</CellPhone>

           <HomePhone>6126634242</HomePhone>

</Technician>

I Know I have to Create the FileDocumentName = Technician

I know that I have to Create XML Document = Technician

For each element I want to retrieve I know I have to as an example

GET XML DOCUMENT DATA "/descendant::Technician/child::HomePhone"

But what is the correct format to select the HomePhone based  WHERE ID is provided of lets say 1234?

/Technician/ID=[1234]/HomePhone

What is the correct format here?

Everyone's tags (1)
12 REPLIES
New Member

Re: UCCX Script XML Select equivalent

You need to set up an Xpath statement to retrieve a specific "record" out of your XML "database";

I  think Anthony Holloway has addressed this quesiton before in this post

https://supportforums.cisco.com/thread/2146082

you might try this approach: create some new variables:

I assume you are prompting callers to enter the ID of a technician?  So in your GetDigits put the result in strID then setup some new variables?

docOptionsFile = DOC[technician.xml]

strXpathBegin  = "//technician[ID="

strXpathEnd = "]/"

strResult

strXpath

Then parse for /CellPhone by ID as follows

Set StrXpath = strXpathBegin + strID + strXpathEnd + CellPhone

strResult = Get XML Document Data (docOptionsFile,strXpath)

Move strResult to whatever value you are using in your script (this could be a subflow)

Rinse, Lather and Repeat the above to get HomePhone

Peter Buswell (aka DrVoIP)
http://blog.drvoip.com

Peter Buswell (aka DrVoIP)
http:/drvoip.com/blog

UCCX Script XML Select equivalent

While reative debugging I get this error when I get to the step GET XML  Document Data (docOptionsFile,strXpaht)

"Can not conver #NUMBER to a NodeList!, nested exception is org.apache.xpath.XPathException" Can not convert #NUMBER  to node list"

duh...

New Member

UCCX Script XML Select equivalent

OK, lets debug and see where things fall apart.

Change your Get XML Documetn Data to the axis format "/descendant::/technician/child::CellPhone"

If that works we know your XML Doc is OK and the Data is OK, the issue is something in the Xpath Statement.

We may have to convert the strID to intID, I think that is what the error is realted to.  I will try to model this in my lab when I get a minute....

Peter Buswell (aka DrVoIP)
http:/drvoip.com/blog

Re: UCCX Script XML Select equivalent

If I use the /descendant format it works!   I can not get the xpath statement to point at the ID I want to retrieve the CellPhone or HomePhone from?  I try various conifguraitons without using the Variables you suggested, by hard coding the GET XML DATA step:

CellPhone = /technician/ID[1234]/CellPhone  which does not crash on the step read, but alwasy brings back NULL.

CellPhone = /technician/CellPhone[ID=1234] which has the same result

And some others that cause the Step to crash....

duh.....

New Member

Re: UCCX Script XML Select equivalent

OK I broke the code on this (sorry for the PUN).   Reformat your XML document to set the ID as an Attribute and put the Phones as Element within the Technicians as follows:

     

           8589451069

           6590

     

     

           7608049733

           6590

     

     

           7025532706

           6590

     

     

           9144718510

           6599

     

The document is the same, but we set the ID as a Unique Record Number (maybe the only reason I can see that anyone would use an Attribute over an Element).   You can not use your [@ID="1234"] to select a specifc Element from the TechnicianList.   So you would setup an Xpath as follows:

strXpath = //Technician[@ID="1234"]/TechnicianCell 

Then stuff your "TechnicianCell = GET XML DATA with strXpath"

You can then Substitue a Variable for the ID so that you can fill it from the GET DIGITS step.  I sometimes find that I have to convert the String value to a int Value, but it works and you should get the desired result.  Take Away = Unique Record ID!

Peter Buswell (aka DrVoIP)
http://blog.drvoip.com

Peter Buswell (aka DrVoIP)
http:/drvoip.com/blog

Re: UCCX Script XML Select equivalent

OK this really helped and we made some really great progress.  We are down to formating the ID as a Variable.  When we hard code this:

strXpath = //Technician[@ID="1234"]/TechnicianCell and stuff it in GET XML DATA it works just fine!!! Yeah!

However, as we need to change the ID based on what the caller enters into the Get Digits Step, we need ID to be a variable.   We have tied both strID and also converting intID = strID but when we stuff it in the strXpath it fails! Ugh!

strXpath = //Technician[@ID=variable]/TechnicianCell fails no matter which format we try. 

Duh....

New Member

UCCX Script XML Select equivalent

you just have to be careful how you format it:

"//Technician[@ID=" + intTechnicianID + "]/" + "TechnicianCell"

Test it and I am sure you will find it works.

Then go back and reassemble your strings

strXpathBegin = "//Technician[@ID="

strXpathEnd = "]/"

The you can set strXpath = strXpathBegin + intTechnicianID + strXpathEnd + "TechnicianCell"

Watch for typo's they are easy to make, but this will work!

Peter Buswell (aka DrVoIP)
http://blog.drvoip.com

Peter Buswell (aka DrVoIP)
http:/drvoip.com/blog

Re: UCCX Script XML Select equivalent

Thanks for working on this all weekend, but I still have an issue! 

All works for the first record only.  So we can parse the XML with the ID as index using the code you provided, and it works like a charm for the first record, in this exmaple 1234 returns the correct value and we can transfer the call. However if you input any other ID, like 1212, the script runs but it does not retrieve a phone number, it comes back null? Your thoughts?

Duh...

UCCX Script XML Select equivalent

Peter has it almost right.  The string must be encapsulated in a single or double quote.  Since you are concatenating strings it is easier to use a single quote.

strXpathBegin = "//Technician[@ID='"

strXpathEnd = "']/"

Use these instead and it should work

-Steven


Please help us make the communities better.  Rate helpful posts!

Please help us make the communities better. Rate helpful posts!

Re: UCCX Script XML Select equivalent

Ok so we might be having a typing mistake,  so here is what we did to rule out any problems with single and double quotes. First we hard code to make sure that it is not an issue with variables:

strXpath = //Technician[@ID="1234"]/TechnicianCell

GET XML DATA with strXpath and it alwasy gives us the CellPhone for ID 1234 and works just fine!

strXpath = "//Technician[ID@intTechnicianID]/TechnicianCell"  This works just fine as well as long as we enter 1234 !

We actually capture GET DIGITS as a stringTechnicianID and the convert it to intTechnicianID.  The result is always the same, we are unable to get anything but the first record to work no matter how we contruct the Xpath Expression.  Any ID other than 1234 does not cause an exception, it just does not work?

Is there a better way to do this? Duh....

Re: UCCX Script XML Select equivalent

I've attached an example of how to do this.   Open the attached script in the UCCX editor and debug it locally.   It helps to step through the script step-by-step.  The results of each query are in the strResult string.

What I do is this:

I first statically grab the first technicians cell and then the second.  Next I use string contcatenation to do the same thing again.  FYI, this script was built using the UCCX 9 editor.


Please help us make the communities better.  Rate helpful posts!

Please help us make the communities better. Rate helpful posts!
New Member

Re: UCCX Script XML Select equivalent

Thanks Steven this clears up the error.  You can not nest double quotes but need to use single quotes.   I was sure the Xpath was right!  On behalf of the about 25+ posts on this forum regarding "only getting the first record"  I thank you! ( I particuarly learned how to stuff an XML document inside the value parameter!  Never would have thought to do that.  A great trick for local debug without the document server)!


I made a video out of this discussion

http://www.youtube.com/watch?v=LUQI1JZclk0

Peter Buswell (aka DrVoIP)
http://blog.drvoip.com

Peter Buswell (aka DrVoIP)
http:/drvoip.com/blog
1033
Views
20
Helpful
12
Replies
CreatePlease to create content