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

Iterate XML with flow

I am currently trying to iterate through a XML file and get the data using Microsoft Flow.

I cannot figure out how to iterate through multiple XML elements. Please see below example.

 

This is my XML data:

 

 

<?xml version="1.0" encoding="utf-8"?>
</ShipmentProfileReport>
<ShipmentProfileReportItem>
<JobOperator>John Doe</JobOperator>
<Master>17231888581</Master>
</ShipmentProfileReportItem>
<ShipmentProfileReportItem>
<JobOperator>Jane Doe</JobOperator>
<Master>78423082032</Master>
</ShipmentProfileReportItem>
</ShipmentProfileReport>

I wish to iterate through all 

<ShipmentProfileReportItem>

items, and get:

 

 

<JobOperator>
<Master>

 

 

This is my flow:

 

 

XML (ShipmentProfileReportItem):

xpath(xml(outputs('XML_File')),'//ShipmentProfileReportItem')

 

 

Compose 2 (Inside foreach):

xpath(xml(item()),'string(.)')

 

This returns:

 

John Doe
17231888581

 

And

JaneDoe
78423082032

However above is just returned as above string. I want to update a sharepoint list. My question is: How can I access the lines seperately? For example:

 

xpath(xml(item("Master")),'string(.)')
xpath(xml(item("JobOperator")),'string(.)')

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Iterate XML with flow

Hi @oliverbusk,

 

Have you tried to use this Expression? As below:

Compose 2

 

xpath(xml(item()),'string(/ShipmentProfileReportItem/JobOperator)') 

Compose3

xpath(xml(item()),'string(/ShipmentProfileReportItem/Master)')   

 

Or these:

 Compose 4

 

xpath(xml(item()),'string(//JobOperator)') 

 Compose 5

 

 

xpath(xml(item()),'string(//Master)') 

 

I followed your Flow tested it on my side and, and I can get these values separately.

20.PNG21.PNG

More details about Xpath function, please check the following article:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#x...

 

More details about Xpath examples, please check the following article:

https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx

 

Best Regards,

Barry

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

3 REPLIES 3
Highlighted
Community Support
Community Support

Re: Iterate XML with flow

Hi @oliverbusk,

 

Have you tried to use this Expression? As below:

Compose 2

 

xpath(xml(item()),'string(/ShipmentProfileReportItem/JobOperator)') 

Compose3

xpath(xml(item()),'string(/ShipmentProfileReportItem/Master)')   

 

Or these:

 Compose 4

 

xpath(xml(item()),'string(//JobOperator)') 

 Compose 5

 

 

xpath(xml(item()),'string(//Master)') 

 

I followed your Flow tested it on my side and, and I can get these values separately.

20.PNG21.PNG

More details about Xpath function, please check the following article:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#x...

 

More details about Xpath examples, please check the following article:

https://msdn.microsoft.com/en-us/library/ms256086(v=vs.110).aspx

 

Best Regards,

Barry

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

Highlighted
Administrator
Administrator

Re: Iterate XML with flow

Hey, @oliverbusk!

Thank you for posting on the Flow Community Forum! It appears as though @v-bacao-msft would like some more information in order to further assist you properly with your issue. Please share any additional information that was requested in order to decrease the amount of time that it will take for you to be assisted!

Thank you for being an active member of the Flow Community!

-Gabriel
Flow Community Manager

-Gabriel
Community Manager
Microsoft Power Automate | Power Virtual Agents
Are YOU a member of a Power Platform User Group?
Fill out This Form to claim your Community User Group Member Badge!
Highlighted
Frequent Visitor

Re: Iterate XML with flow

Coming 1.5 years later.

Thank you for the reply above.

Scalable solution with just one Apply to each.

 

(works with xmlns in my case, just had to replace a few strings to compose a new xml and iterate in the new one).

kudos

Helpful resources

Announcements
secondImage

August 2020 CYST Winners!

Check out the winners of the recent 'Can You Solve These?' community challenge!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Top Kudoed Authors
Users online (5,572)