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 / Retrieve an object ins...
Power Automate
Answered

Retrieve an object inside of XML tag and convert it to JSON

(0) ShareShare
ReportReport
Posted on by 9

Hi, 

I am trying to retrieve a string within an XML response and convert it into JSON format to return in a Response connector. So far I have been unable to access the value needed in <ResultData>. 

 

 

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <soap:Body>
 <GetAllPeopleResponse xmlns="http:......">
 <GetAllPeopleResult>
 <ResultCode>200</ResultCode>
 <ResultText>OK</ResultText>
 <SurpassRef>-1</SurpassRef>
 <RemoteRef />
 <ResultData xsi:type="xsd:string">{
 "data": [{
 "ID": 3,
 "Name": "Joe Smith",
 "Color": "#FF8C00"
 },
 {
 "ID": 13,
 "Name": "Ed Jones",
 "Color": "#48D1CC"
 },
 ]}
 </ResultData>
 </GetAllPeopleResult>
 </GetAllPeopleResponse>
 </soap:Body>
</soap:Envelope> 

 

 

 

 

Screen Shot 2020-06-26 at 4.51.21 PM.png

This Flow is invoked by an HTTP Request from an application, which the Flow then proceeds to call an API that returns the XML data. I'm missing a step between "Compose" and "Response" where I hope to be able to convert the string (that looks like JSON) into JSON format, but first I need the string!

 

"Compose" is using an expression and this is where I'm getting stuck

 

xpath(xml(body('HTTP')), '//Envelope')

 

 

 

I can't seem to get beyond the first element. This expression above returns an empty array. Anything else has returned an invalid xpath parameter. 

 

The end result is to have this Flow called by a custom connector that returns JSON. 

 

 

Any insight is appreciated!

 

Thanks in advance. 

Categories:
I have the same question (0)
  • Verified answer
    antman Profile Picture
    9 on at

    I found the error in xpath. 

     

    What I needed was:

    xpath(xml(body('HTTP')), '//*[local-name()="ResultData"]/text()')

     

    Until next time...

  • mcin9781 Profile Picture
    Microsoft Employee on at

    Thanks for the follow up, and hopefully somebody will find this useful in the future.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard