Execute x path activity with namespace


#1

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…


#2

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!


#3

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!


#4

Wondering if you were able to resolve this issue.


#5

#6

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!


#7

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