Hi @gunnery,
It is returning the token as an XML string. The quickest, and slightly crude, way of dealing with it would be to manipulate the string to extract just the token. You should be able to use: {{api1.data.split("</result>\n ")[1].split("</token>")[0]}}
It will return everything after the result tag, newline character and space. It then returns the string before the token tag leaving you with just the token. If the provider change or reorder their XML, you may have to adjust the code.
Is there always a space at the start of the token? I’m wondering whether the escaped output may be causing the split lookup string to not match as what I posted was based on that escaped version. You could split on result> (rather than </result>/n ) before then splitting on the space. Something like: {{api1.data.split("result>")[1].split(" ")[1].split("</token")[0]}}
It seems as though any PHP function options may be limited as the XML string doesn’t appear to be correctly structured. The fields usually fall inside a single tab e.g. <records></records> in the following <records> <field1></field1> <field2></field2> <record1> <recordfield1></recordfield1> <recordfield2></recordfield2> </record1> <record2> <recordfield1></recordfield1> <recordfield2></recordfield2> </record2> </records>
Unless a field is empty it should also have both opening and closing tags.
These 2 issues, afik, will cause the usual PHP functions to throw errors leaving string manipulation as your only option.
Cheers @bpj for your help but still the same issues.
I think this one will have to go in the too hard basket at the moment.
I’ve flicked an email to the supplier asking if they can supply a JSON API as the XML is outdated.
Going to have to work another way around this at the moment I think.