08-06-2014 07:26 AM - edited 03-14-2019 01:43 PM
I'm looking to have a single script read individual CSQ prefs from an XML file. When I test with static values for the CSQ name in the Get XML Step, I get null values returned if the string is text. If it is numeric, it works.
This one fails with 'null' returned to the opt_ManualCloseCSD variable:
"/descendant::prefs/child::CSQ[@ID=CustomerService]/child::opt_ManualCloseCSD"
<?xml version="1.0" encoding="UTF-8"?>
<prefs>
<CSQ ID="CustomerService">
<opt_ManualCloseCSD>true</opt_ManualCloseCSD>
</CSQ>
<CSQ ID="SAS">
<opt_ManualCloseCSD>false</opt_ManualCloseCSD>
</CSQ>
</prefs>
This one succeeds and sets the opt_ManualCloseCSD to true:
"/descendant::prefs/child::CSQ[@ID=12345]/child::opt_ManualCloseCSD"
<?xml version="1.0" encoding="UTF-8"?>
<prefs>
<CSQ ID="12345">
<opt_ManualCloseCSD>true</opt_ManualCloseCSD>
</CSQ>
<CSQ ID="SAS">
<opt_ManualCloseCSD>false</opt_ManualCloseCSD>
</CSQ>
</prefs>
Any assistance appreciated.
Brian
Solved! Go to Solution.
08-06-2014 10:23 AM
[@ID='" + var_CSQ + "']
Notice the Single Quote right next to the Double Quote before the Variable and after the Variable..it's really:
String s1 = "/descendendant::prefs/child::CSQ[@ID='";
String s2 = "']/child::opt_ManualCloseCSD";
String s3 = s1+var_CSQ+s2;
08-06-2014 09:01 AM
Wrap All of them in Single Quotes: @ID='CustomerService' (even the "numerics" even though they work in XPath without them)..
08-06-2014 10:14 AM
That worked, thanks Sam.
So how do I include the variable in the Get XML step?
Here's the static value:
"/descendant::prefs/child::CSQ[@ID='CustomerService']/child::opt_ManualCloseCSD"
My attempts to use this fail:
"/descendant::prefs/child::CSQ[@ID=" + var_CSQ + "]/child::opt_ManualCloseCSD"
08-06-2014 10:22 AM
By the way, I also tried this variant which includes the double-then-single quote marks recommendation from Dr. VoIP's but no luck.
"/descendant::prefs/child::CSQ[@ID="' + var_CSQ + '"]/child::opt_ManualCloseCSD"
The error I receive when I attempt to save the edit is "Unable to parse expression; un-terminated character: ' (line: 1, col: 37)."
08-06-2014 10:25 AM
this ' needs to be part of the String (in the case where you are getting a bad expression UNTERMINATED..Terminated means this: "'"
08-06-2014 10:34 AM
Actually this worked perfect:
"/descendant::prefs/child::CSQ[@ID='" + var_CSQ + "']/child::opt_ManualCloseCSD"
I do not use variables for the prefix/suffix of the XPath ... just for the CSQ.
So it turns out I just had the quotes reversed.
Regardless, thanks Sam!
08-06-2014 10:27 AM
Ah, ok. I see the difference. You have single-then-double, NOT double-then-single. Okay ... trying that out. Will report back. Thanks!
08-06-2014 10:23 AM
[@ID='" + var_CSQ + "']
Notice the Single Quote right next to the Double Quote before the Variable and after the Variable..it's really:
String s1 = "/descendendant::prefs/child::CSQ[@ID='";
String s2 = "']/child::opt_ManualCloseCSD";
String s3 = s1+var_CSQ+s2;
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide