web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / XML XPath Expression I...
Power Automate
Unanswered

XML XPath Expression Invalid - Desktop Flow

(0) ShareShare
ReportReport
Posted on by

My Desktop flow starts off with me invoking a SOAP web service to obtain a Error Code and Caller Token which will be used in a further web service to go on to update a workers details in a system. I first need this Error Code to do a validation whether the web method was successful or not and then obtain the Caller Token if it is.

 

The SOAP web service has been successful where I get the correct response code which is the following:

 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><AuthenticateCallerResponse xmlns="http://NHSP.StaffBankInterface"><AuthenticateCallerResult xmlns:a="http://schemas.datacontract.org/2004/07/BbyB.StaffBank_NHSP.StaffBankInterface" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:ErrorCode>0</a:ErrorCode><a:ErrorDescription i:nil="true"/><a:ResponseId>1</a:ResponseId><a:CallerToken>xVLwjsgwtYwejWDSAVOoq60VM94gMb4pxp

oqmTfLwjt3HesWm6QG7mXtxb8a1MpzWkzEzcGL7MKbWfObr%2fpjNNapC1GzGBsj0b56%2bMa8FkVMe26Uf1Pq%2bQ%3d%3d</a:CallerToken><a:ExpiresOn>2022-09-06T09:54:40.555625+01:00</a:ExpiresOn></AuthenticateCallerResult></AuthenticateCallerResponse></s:Body></s:Envelope>

 

As you can see the response code includes the Error Code and Caller Token, so therefore I need to pull the Error Code from this response to check the numeric value.

 

As this response is in a text format and I need it to be in XML to be able to use the Xpath expression. I wrote the response code into an XML file using the correct encoding. Then after reading the XML file and storing as a variable this is what the structure of the response code looks like now:

 

 

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
 <s:Body>
 <AuthenticateCallerResponse xmlns="http://NHSP.StaffBankInterface">
 <AuthenticateCallerResult xmlns:a="http://schemas.datacontract.org/2004/07/BbyB.StaffBank_NHSP.StaffBankInterface" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
 <a:ErrorCode>0</a:ErrorCode>
 <a:ErrorDescription i:nil="true" />
 <a:ResponseId>1</a:ResponseId>
 <a:CallerToken>xVLwjsgwtYwejWDSAVOoq60VM94gMb4pxpoqmTfLwjt3HesWm6QG7mXtxb8a1MpzWkzEzcGL7MKbWfObr%2fpjNNapC1GzGBsj0b56%2bMa8FkVMe26Uf1Pq%2bQ%3d%3d</a:CallerToken>
 <a:ExpiresOn>2022-09-06T09:54:40.555625+01:00</a:ExpiresOn>
 </AuthenticateCallerResult>
 </AuthenticateCallerResponse>
 </s:Body>
</s:Envelope>

 

 

Then using the "Get XML element value" I enter the variable for the XML document as shown above and use the Xpath query "/s:Envelope/s:Body/AuthenticateCallerResponse/AuthenticateCallerResult/a:ErrorCode" to get the output variable as a numeric value.

 

The error message I receive from this action is the following:

 

"Invalid XPath expression provided"

"Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function."

 

I've tried many different type of XPath expressions but it still come back as invalid and so far the only expression that has worked is "//*" where it returned all of the element values in one string which is not helpful in my case.

 

Any assistance would be appreciated.  I can supply more detail if required.

I have the same question (0)
  • AlanCave Profile Picture
    5 on at

    Did you ever figure this out?
    I have the same issue with the error 'Invalid XPath expression provided'. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 272 Super User 2026 Season 2

#2
trice602 Profile Picture

trice602 147 Super User 2026 Season 2

#3
11manish Profile Picture

11manish 146 Super User 2026 Season 2

Last 30 days Overall leaderboard