cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bouillons
Resolver I
Resolver I

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
Resolver I
Resolver I

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
Super User
Super User

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
Super User
Super User

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
Resolver I
Resolver I

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

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Users online (2,306)