Skip to main content

Notifications

Community site session details

Community site session details

Session Id : M1X3eVZ5xZOzQNy1OdE1rI
Power Automate - Building Flows
Answered

XML to JSON Conversion

Like (0) ShareShare
ReportReport
Posted on 7 Jul 2022 07:34:43 by 173

HI,

 

I am trying to decode a SOAP message and bring the data back to a Power App. I have managed to get the data from the webservice, and decoded the answer with decodeBase64. But I think I need to get rid of some unneccessary data, and I don't know how to do this. 

The actual result look like this:
<?xml version="1.0" encoding="iso-8859-1"?><result>
<row index="1">
<NAMN index="0">Innovatum Portfolio AB</NAMN>
<ORGNR index="0">556546-1992</ORGNR>
</row>
<row index="2">
<NAMN index="0">Innovatum AB</NAMN>
<ORGNR index="0">556546-2008</ORGNR>
</row>
<row index="3">
<NAMN index="0">Innovatum Science Center AB</NAMN>
<ORGNR index="0">556556-7301</ORGNR>
</row>
<row index="4">
<NAMN index="0">Innovatum Progress AB</NAMN>
<ORGNR index="0">556887-6592</ORGNR>
</row>
<row index="5">
<NAMN index="0">Stiftelsen Innovatum</NAMN>
<ORGNR index="0">863001-1057</ORGNR>
</row>
</result>

What I want is just the NAMN and ORGNR for each row. Does anyone have any ideas?

  • Verified answer
    Expiscornovus Profile Picture
    31,652 Most Valuable Professional on 07 Jul 2022 at 09:37:15
    Re: XML to JSON Conversion

    Hi @LennartWalldén,

     

    If you want JSON format we can use the json function. We probably don't need xpath in that case.

     

    In the From field of the Select action I am using this expression

     

    json(xml(outputs('Compose')))['result']['row']

     

     

    In the Map field I am using the following expression for the value fields:

     

    item()?['NAMN']['#text']
    item()?['ORGNR']['#text']

     

    noxpathneeded.png

     

    That should give you an output format like below. Hopefully that is what you are looking for?

     

    noxpathneeded02.png

     

  • LennartWalldén Profile Picture
    173 on 07 Jul 2022 at 09:15:00
    Re: XML to JSON Conversion

     Hi @Expiscornovus,

     

    Thanks for the reply.
    Looks good, but I also would like to get rid of all the indexes and only keep the value. Is that possible?

    I would like the result as an array in JSON format so I can read it back to my PowerApp via an array variable.

  • Expiscornovus Profile Picture
    31,652 Most Valuable Professional on 07 Jul 2022 at 08:25:19
    Re: XML to JSON Conversion

    Hi @LennartWalldén,

     

    You could use an xpath function for that. In what format do you want the results? 

     

    Below is an example of how you could use xpath.

     

    xpath(xml(outputs('Compose')), '/result/row/NAMN | /result/row/ORGNR')

     

    xpath_example.png

     

    With this setup the result will look like below.

     

     

    xpath_example02.png

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,745 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,091 Most Valuable Professional

Leaderboard
Loading started