This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.
The final query expression we will be decomposing today is this:
This is the XPath function (https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#xpath).
We assume there is a count string typed variable containing the XML payload to query into. The variables function looks-up that variable (https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#variables).
The XML function (https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#xml) parses that string input to an XML document which the XPath function expects as first input.
Then comes the XPath itself
First
allows to select all 'lists' named elements at root level without consideration for namespace. Beware many online XPath test tools will ignore the input XML document namespace, while .NET, and Logic Apps XPath function built with .NET, honor the namespace. So for a node to match with just
it needs to be
with no namespace assigned. Beware children nodes inherit default namespaces assign by their parents (
).
Second
lets you select all the name nodes where the name value is '*Billable'. It is typical to want to select elements from an XML array which have specific value for a child node or attribute. This demonstrate selecting the name nodes equal to *Billable.
Third
lets you go back to the parent node of the name node, so you are able to list all the 'list' elements which satisfied the condition on their leave nodes (has a name element of value *Billable).