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

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.

View solution in original post

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

 

Now for my next Power Automate challenge... 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (2,468)