cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
asmith2
Regular Visitor

SharePoint list items to xml file

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!

4 REPLIES 4
eliotcole
Power Participant
Power Participant

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.

 

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
Power Participant
Power Participant

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

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

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!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Users online (2,509)