cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
afdawson
Frequent Visitor

Parsing an XML file and creating a table / fields that can be mapped into an email

Hi All, 

 

I'm new to Power Automate, and I'm trying to setup a Power Automate for loading an XML file from an FTP server, and parsing the file so that the contents of the file appear in an email message. I've got the basics in place, so I can load the file from the FTP server (or at least, should be able to), and Power Automate sends an email containing the XML, but it's not that readable. I've had a play and can pull data out of the first XML fields, but I am struggling to get the data in subsequent fields out, so I can properly format the message. 

The XML is formated like:

<OpenOrderReport>

<ItemOrdered>

<OrderNumber>ABC-1234</OrderNumber>

<Status>Text Here</Status>

</ItemOrdered>

<ItemOrdered>

<OrderNumber>ABC-5678</OrderNumber>

<Status>Text Here</Status>

</ItemOrdered>

</OpenOrderReport>

 

Does anyone have any suggestions? I'm guessing I need to use an apply to each, but I've struggled to work out how to pull the data out of the apply to each 😞

 

Thanks in advance, 

Alan

1 ACCEPTED SOLUTION

Accepted Solutions

 

Hi @afdawson ,

 

Maybe you could create an HTML table to display the extracted data.

  • Initialize an array variable to store the data which needs to be displayed in Html table.
  • Append the extracted data to the array variable.
  • Finally, create an HTML table and configure the output of HTML action in the email body.

Image reference:

120.PNG

Details in Apply to each:

121.PNG

Hope this helps.

 

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

6 REPLIES 6
Jcook
MVP

Hello @afdawson

My suggestion is to convert the XML into JSON.
That way you can parse each field.

Check out my solution on this post:
https://powerusers.microsoft.com/t5/Building-Flows/Reading-xml-file-from-onedrive/m-p/452156


—Josh
If you like my post please hit the "Thumbs Up" -- If my post solved your issue please "Mark as a Solution" to help others

Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





v-bacao-msft
Community Support
Community Support

 

Hi @afdawson ,

 

You could use Xpath() function to parse XML data and extract data by node name.

Please refer to the similar thread and see if it helps:

https://powerusers.microsoft.com/t5/Building-Flows/Iterate-XML-with-flow/m-p/163734#M16546

https://powerusers.microsoft.com/t5/General-Power-Automate/Parse-XML-using-Microsoft-Flow/td-p/11492...

You could also refer to the following expression to extract data.

113.PNG

Compose 2:

xpath(xml(outputs('Compose')),'//ItemOrdered') 

OrderNumber:

xpath(xml(item()),'string(/ItemOrdered/OrderNumber)') 

Status:

xpath(xml(item()),'string(/ItemOrdered/Status)') 

Please take a try and feel free to let us know if you have any other questions.

 

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.

@v-bacao-msft I've tried this approach before, what I have had trouble with is getting the data out of the Apply to Each into my email, it could be I'm looking in the wrong place for selected the appropriate fields in the email part? 

Hi @afdawson

Please refer to my solution in this post:
https://powerusers.microsoft.com/t5/Building-Flows/Unable-to-reference-fields-outside-of-apply-to-ea...

—Josh
If you like my post please hit the "Thumbs Up" -- If my post solved your issue please "Mark as a Solution" to help others

Did I answer your question? Mark my post as a solution!

If you like my post please hit the Thumbs Up


Proud to be a Flownaut!


Check out my blog for Power Automate tips,
tricks, and guides
FlowAltDelete





 

Hi @afdawson ,

 

Maybe you could create an HTML table to display the extracted data.

  • Initialize an array variable to store the data which needs to be displayed in Html table.
  • Append the extracted data to the array variable.
  • Finally, create an HTML table and configure the output of HTML action in the email body.

Image reference:

120.PNG

Details in Apply to each:

121.PNG

Hope this helps.

 

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.

Thanks, @v-bacao-msft and @Jcook for your help. I have this sorted now 🙂

 

Now for my next Power Automate challenge... 

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.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (4,792)