cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
crmkeeper
Advocate II
Advocate II

xPath parsing noob

I don't really have any idea what I am doing, but trying to get a value from this response.

There is only one field in the return, and i see it when I send to email. 

HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <LoginResponse xmlns="http://...../webservices">
      <LoginResult>string</LoginResult>
    </LoginResponse>
  </soap12:Body>
</soap12:Envelope>

I have tried to read most blog post, but I just can't get it to work. I am all over the place with xPath 🙂 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

Hi @crmkeeper ,

 

The issue might be because of the Namespaces in your XML. Please try to use the following expression to get the string.

Expression reference:

xpath(xml(outputs('Compose')), '//*[local-name()="Envelope"]/*[local-name()="Body"]/*[local-name()="LoginResponse"]/*[local-name()="LoginResult"]/text()')[0]

Image reference:
14.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-bacao-msft
Community Support
Community Support

 

Hi @crmkeeper ,

 

The issue might be because of the Namespaces in your XML. Please try to use the following expression to get the string.

Expression reference:

xpath(xml(outputs('Compose')), '//*[local-name()="Envelope"]/*[local-name()="Body"]/*[local-name()="LoginResponse"]/*[local-name()="LoginResult"]/text()')[0]

Image reference:
14.PNG

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

I owe you a beer!!! ❤️

I have no idea how I would be able to understand this without you. Do you mind sharing what I should think about next time i see a similar XML? I am not 100% sure what namespaces are but gessing it is related to the "Soap12:Envelope", and it not just being "Envelope"?

 

Also could you try to explain why you use //* in the beginning? 
Can I use the "local-name" every time even if there is a namespace issue or not? 
I see you added the /text() at the end and that, and others have put things in a String(' '). I am guessing that is the same result? 

The end [0] you are treating it like an array, is that because there could be more than one response? 

 

Thank you again for helping me with this!!:)

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (59,411)