Execute x path activity with namespace

I’m trying to use the “Execute x path activity” to parse the XML below (passed in as a String in the XMLString property), but getting the error:

Execute x path : Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.

I use the following xpath query in XPathExpression:

“/soapenv:Envelope/soapenv:Body/cus:getCustomerByCprOrAgreementRes/cus:customerIdentification/*[local-name()=‘cpr’]”

on the XML:

<SOAP-ENV:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cus="http://customerservice.flash.com/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><getCustomerByCprOrAgreementRes xmlns="http://customerservice.flash.com/"><customerIdentification><customerNo xmlns="http://customer.flash.com">69485049</customerNo><cpr xmlns="http://customer.flash.com">1234567890</cpr><name xmlns="http://customer.flash.com">Lx Mx Nx</name><customerCategory xmlns="http://customer.flash.com">KUN</customerCategory><customerType xmlns="http://customer.flash.com">KVI</customerType></customerIdentification><errorCode>0</errorCode><errorText>Total of record(s) : 01</errorText></getCustomerByCprOrAgreementRes></SOAP-ENV:Body></SOAP-ENV:Envelope>

Anyone knows why ? - query is valid according to other xpath parsers…

Hi I have the same issue. I am trying to parse the message below SOAP response, but am unable to parse it with XPATH.

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope 
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<OpenResponse xmlns="http://bvdep.com/webservices/">
<OpenResult>Q7V2DTE635HZAJ5</OpenResult>
</OpenResponse></soap:Body>
</soap:Envelope>

This is the response I receive from UiPath

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

Is there a comprehensive guide on how to work with XPATH and SOAP results?

Thanks in advance!

Hi, what I just tried is to omit the whole

/soap:Envelope/soap:Body

part and I just started with

//OpenResponse/OpenResult[1]

and it worked perfectly!

Wondering if you were able to resolve this issue.

HI, I deserialized and applied xpath but still, I get the same error message as you did. I will not post the whole xml but using shortened “//D:OF[1]” (as @vsadykov stated) neither full “are:Ares_odpovedi /are:Odpoved/D:Vypis_RZP/D:ZAU/D:OF[1]” xpath worked.

Is there a solution to the namespace manager as suggested in the error message?
Thank you!

Have you tried using a namespace manager? If not, please check the sample workflow in this post: Reading XML Attribute out of Uipath Xaml file - #2 by Mateus_Cruz

Hi, I have found this topic useful but I thought my scenario might add value.

I was trying to make XPATH work for an XML document that had a namespace, but no short name.
A simplified form of the XML is:

<?xml version="1.0" encoding="utf-8"?> David Martin david.martin@ether-solutions.co.uk

I struggled to XPATH to work, as the namespace did not have a shortname e.g. abc

The solution which I hope might help others, is that once the XML file had been read into the string variable - myXMLString, as well as being processed with XPATH, it can also be edited without impacting the XML on the file system. Therefore, a simple string Replace, to remove the namespace e.g. Replace(“xmlns=”“https://www.myite.uk/test”"","")

This simplifies the XML and XPATH works perfectly with the updated string variable. Seems obvious with hindsight but not so apparent when you looking at the source XML file on the file system.

“string(/OrderAcknowledgement/header/yourname/text()[1])”