Search code examples
azure-logic-apps

Azure Logic App - xpath for xml with namespace prefix


In my logic app i am using xpath() function to get the value of . I have tried different xpaths but getting error

'The template language function 'xpath' parameters are invalid: the 'xpath' parameter must be a supported, well formed XPath expression. Please see https://aka.ms/logicexpressions#xpath for usage details.'.

i have the following xml:

enter image description here

I have tried:

@xpath(xml(<YourMessage>), '/*[local-name()=\"Envelope\" and namespace-uri()=\"http://schemas.xmlsoap.org/soap/envelope/\"]/*[local-name()=\"Body\" and namespace-uri()=\"http://schemas.xmlsoap.org/soap/envelope/\"]')
@xpath(xml(<YourMessage>), 'string(/*[local-name()=\"Envelope\" and namespace-uri()=\"http://schemas.xmlsoap.org/soap/envelope/\"]/*[local-name()=\"Body\" and namespace-uri()=\"http://schemas.xmlsoap.org/soap/envelope/\"])')

but getting the same error enter image description here


Solution

  • You might be better off converting to JSON and working with the data in that format. At least you can get rid of all the silly namespace complexities that way.

    LogicApps is JSON focused internally so doing so would be slightly more 'correct' anyway.

    You can find samples at: JSONPath - XPath for JSON

    And an evaluator: JSONPath Online Evaluator