cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2079
Views
0
Helpful
7
Replies

Issue Reading XML files

mightyking
Level 6
Level 6

Hello Experts,

I am trying to read an XML file which contains some Area Codes in order to route the calls either localy or long distance. Please see the attached screenshot and let me know if I am missing something.

 

 

Thanks,

 

MK

1 Accepted Solution

Accepted Solutions

MK:

I reviewed the photo you uploaded...  The error is occurring because of a mismatch of the named variables being used. 

In the solution provided, these have been changed in your image and do not match:

2020-0108-variableMismatchDetails.png

Look closely in yours, again, and you will see why.

...working with named variables that have similar spelling, can create this kind of confusion if you don't keep a close eye on what is being assigned, and where.

In the sample above, the callback number variable is being used with the substring function to select the area code from the string.  That resultant string is being used to search the document data as part of the XPath string in the next step.  In your pic, you are using a different named variable than the one in the previous step.

Watch-out, because the next step in your pic has the same issue.  It will not evaluate properly, because of an incorrectly assigned named variable.

 

Hope this helps.

-Sean

View solution in original post

7 Replies 7

Sean Lynch
Level 7
Level 7

I believe the problem exists in the format/syntax of your XPath expression you are attempting to use in the "Get XML Data" steps:

Untitled.png

 

In my sample solution, I've created 3 document data variables to show various ways to script the XPath value; variables below:

Capture-3.PNG

 

In the sample solution below, it executes 3 Get XML Document Data steps against your XML Document and reads for the same value; all in different ways (Static with predicates, shorted with predicates, and shortened with an integer variable for the same):

Capture-1.PNG

 

(the last Get XML Document Data step uses variables as shown assigned before the step executes)

Capture-4.PNG

 

Here's the sample output for the zip code found at item#545 using all three methods:

Capture-2.PNG

 

I hope these examples help show the difference in XPath syntax.

-Sean

Hi Sean,

Thank you for taking the time and responding.

I am trying to use the shortend Xpath using variable but don't seem to have luck. I am attaching the script for your review. Could you please let me know where I am mistaken?

 

Thanks,

 

MK

Hmmm...  Okay.  Now I see what you were attempting.

 

This is how I was able to evaluate that long list of AreaCodes using the Short method.  Sample pic:

Capture-1.PNG

I set the xpath variable to: "//AreaCode[AreaCode=" + sAreaCode + "]"

The String variable returned is actually not useful.  It's the 'null' expression you want to evaluate (area code not found is returned as 'null').

 

Variables used in the Sample:

Capture-2.PNG

 

...what I learned in this exercise is that XPath in UCCX does not allow Boolean expressions to be returned/evaluated:

2020-0103-uccxBooleanXPath.png

//AreaCode/AreaCode=343202 == true

...UCCX doesn't like this.

 

Let me know if this helps.

-Sean

 

Hi Sean,

Please find attached the screenshot of the error message I receive.

 

Thanks,

 

MK

MK:

I reviewed the photo you uploaded...  The error is occurring because of a mismatch of the named variables being used. 

In the solution provided, these have been changed in your image and do not match:

2020-0108-variableMismatchDetails.png

Look closely in yours, again, and you will see why.

...working with named variables that have similar spelling, can create this kind of confusion if you don't keep a close eye on what is being assigned, and where.

In the sample above, the callback number variable is being used with the substring function to select the area code from the string.  That resultant string is being used to search the document data as part of the XPath string in the next step.  In your pic, you are using a different named variable than the one in the previous step.

Watch-out, because the next step in your pic has the same issue.  It will not evaluate properly, because of an incorrectly assigned named variable.

 

Hope this helps.

-Sean

Sean,

That was exactely my mistake.

 

Thank you very much, I appreciate your help.

 

MK

 

 

You're welcome!
-Sean