web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Automate
Answered

Iterate XML with flow

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

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(.)')

 

Categories:
I have the same question (0)
  • Verified answer
    v-bacao-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    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

  • GabrielStJohn Profile Picture
    Microsoft Employee on at

    Hey, @Anonymous!

    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

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 427

#2
Vish WR Profile Picture

Vish WR 316

#3
David_MA Profile Picture

David_MA 260 Super User 2026 Season 1

Last 30 days Overall leaderboard