cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bouillons
Helper V
Helper V

Convert array to xml without apply to each ?

Hi, I have a simple array of items that I want to convert to XML in power automate. The xml() function does not allow arrays as input. Has anybody found a way to workaround this limitation ? There's an example using apply to each which is too slow for my scenario.

 

Stephane

1 ACCEPTED SOLUTION

Accepted Solutions
bouillons
Helper V
Helper V

Using a compose action, I was able to convert the array to xml. The expression I'm using is:

 

xml(json(concat('{"list": {"item": [',join(body('Result Array of Select'),','),']}}'))) 
 
bouillons_0-1638193906511.png

 

 

 

View solution in original post

3 REPLIES 3
mahoneypat
Solution Sage
Solution Sage

I didn't have time to finish but I adapted the approach used in this article (perhaps the one you saw).  Basically you use two Selects.  The first packages each JSON object in your array into a single-element object (for the XML function to work); I called mine Result but you can substitute.  The second Select extracts the $content of the created XML and converts that binary to a string.

Solved: convert json output into xml - Power Platform Community (microsoft.com)

 

mahoneypat_0-1637885632165.png

Here is what the above looks like.  From here you can do the join step and add the header as described in the solution above.

mahoneypat_1-1637885668390.png

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Solution Sage
Solution Sage

Have you already turned up the concurrency for your Apply to each to speed it up?

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


bouillons
Helper V
Helper V

Using a compose action, I was able to convert the array to xml. The expression I'm using is:

 

xml(json(concat('{"list": {"item": [',join(body('Result Array of Select'),','),']}}'))) 
 
bouillons_0-1638193906511.png

 

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (7,477)