I have receiving an XML payload response target system that follows the following structure...
<Something> <SomethingElse> <Item> <Id>001</Id> </Item> <Item> <Id>002</Id> </Item> </SomethingElse> </Something>
and am trying to use an Extract Variables policy to obtain an array of the values.
Typically we have converted the XML to JSON and manipulated it from there, however in this case it seems like overkill.
If I use the below XPath in an online tool such as this, then a list of values are returned.
//Id/text()
However if I use this XPath in the Apigee Extract Variables policy like this...
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ExtractVariables async="false" continueOnError="false" enabled="true" name="extractId"> <DisplayName>extractId</DisplayName> <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> <Source clearPayload="false">calloutForSomething.content</Source> <XMLPayload> <Variable name="something.id"> <XPath>//Id/text()</XPath> </Variable> </XMLPayload> </ExtractVariables>
Then the variable 'something.id' is set to the string "001", rather than an array.
I am not sure whether I need to amend the XPath or if this is a limitation of the Extract Variables policy.
Thanks in advance, Sean
Solved! Go to Solution.
Hi Sean, unfortunately with Extract Variables you can't get the arrays. Your first approach is easier, XMLtoJSON and working with it, or you could do xpath in java or python or js
Thanks,
Hi Sean, unfortunately with Extract Variables you can't get the arrays. Your first approach is easier, XMLtoJSON and working with it, or you could do xpath in java or python or js
Thanks,
Ok perfect, many thanks!