Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

SharePoint list items to xml file

(0) ShareShare
ReportReport
Posted on by 39

Hi, I'm trying to create an xml file from SharePoint. I'm having trouble and pretty much the information I find is creating items from xml...What I've been trying so far is:

1. Get items from SharePoint list (custom columns)

2. Format item information into variable (loop)

3. Compose xml from variable information

4. Save xml document

 

It was successful until I tried setting my variables to get the custom information I need into the xml file. It Automatically creates an Apply To Each loop, and when I try referencing it I get an error.

 

Is there something I'm missing? Is there an easier way to go about it?

 

I appreciate any insight!

  • asmith2 Profile Picture
    39 on at
    Re: SharePoint list items to xml file

    Those look really useful. I'll test out that method. Thanks!

  • eliotcole Profile Picture
    4,243 Super User 2025 Season 1 on at
    Re: SharePoint list items to xml file

    OK, I'll see if I can work it out, but it might be out of my wheelhouse, as I'm new to XML.

     

    You'll definitely want to look at using expressions with xpath() and xml() to create the XML, though.

     

    I recently adapted @JohnLiu's excellent XML hack to basically write something that can parse any single JSON object into XML over here on Stack. Just remove the filter step that removes empty entries, and the conversion back to a JSON array, and you're looking good!

     

    Additionally, it might be worth contacting the government agency, most websites that have a submission form that accepts the data will quite possibly accept other methods (like JSON).

  • asmith2 Profile Picture
    39 on at
    Re: SharePoint list items to xml file

    Perhaps I should start from the beginning, as it's completely possible that what I've done so far is wrong. 🙂

     

    We are uploading documents into a federal site. This site requires an XML file, with certain formatting.

     

    I have a SharePoint list connected to a form that the employees fill out. Then I am needing a flow that takes the items from the list, and makes them into XML files (or file, with each item as it's own page).

     

    An example of the formatting necessary (taken from the federal guidelines):
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE CashServices SYSTEM "CashServices.dtd">
    <CashServices>
               <CashOrder>
                       <BranchAba>121999999</BranchAba>
                       <BranchNbr>0001</BranchNbr>
                       <FrbOffice>041000014</FrbOffice>
                       <ShipDate>10/20/2009</ShipDate>
                       <CurcyOrderFit>
                                   <CurcyOrder1>1000</CurcyOrder1>
                       </CurcyOrderFit>
                       <CoinOrderBag>
                                   <CoinOrder10>2000</CoinOrder10>
                       </CoinOrderBag>
               </CashOrder>
    </CashServices>

     

    I've taken the items from the sharepoint list, so each item will fill in the 
    -Branch ABA

    -BranchNbr

    -FrbOffice

    -ShipDate

    -Order amounts

    -Order totals

     

    After looking around, I saw people take the information and do a couple things to do...create html information to convert to an xml...or...put the information into a variable and then use the compose->xml...

     

    Creating a variable is what I tried to mimic. 

    It works IF I do it this way:

    asmith2_0-1620329244681.png

    But then you end up with a ton of different documents...from each item on the list...

     

    Is there not a way to take the information from the list...and create ONE xml document where the items are on different pages? (to be done every day, at the end of the day)

  • eliotcole Profile Picture
    4,243 Super User 2025 Season 1 on at
    Re: SharePoint list items to xml file

    Could you give us an example of some of the data you're working with, and perhaps some screenshots of the flow, please @asmith2 ?

     

    If you edit the initial question with them it'll maybe also help further.

     

    ---

     

    Suffice to say, purely thinking about a field in a given JSON object, you can get the value of a field from another action using either outputs(), body(), variable(), or some others, with a query on the individual field using a question mark and then square brackets enclosing the field name in single quotes.

     

    So if I had pushed a JSON object in to a variable called jsonVAR, and in a subsequent action I wanted only the 'date' field's value from that I would use:

     

    variable('jsonVAR')?['date']

    This works differently with an array.

     

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1