cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Ingest XML to SharePoint list with Power Automate and xPath

Good morning,

I am newer to working with Power Automate so please bear with me.

I am trying to create a flow to take some XML code, parse it and apply the data set to a list in SharePoint. I have found this solution to be helpful in the initial creation of the process:

 

https://powerusers.microsoft.com/t5/Building-Flows/Import-XML-to-SharePoint-list-with-Flow-and-xpath...

 

I was successfully able to take out a single data point and push it to a SharePoint list, however, I am running into an issue with how to pull the second set of data into the list, please see the process below:

 

Compose XML:

In the end, this XML will be pulled from a file dropped within a SharePoint library, but for now we are using this example XML created within the flow.

 

 

<?xml version="1.0" encoding="UTF-8"?>
<Party>
<Table>
<Id>4736</Id>
<CompanyId>Target</CompanyId>
<PersonId>1138</PersonId>
<Created>2009-12-31T22:02:52.493Z</Created>
<IsDeleted>false</IsDeleted>
</Table>
<Table>
<Id>4752</Id>
<CompanyId>King Soopers</CompanyId>
<Created>2010-08-24T22:47:44.177Z</Created>
<IsDeleted>false</IsDeleted>
</Table>
<Table>
<Id>4753</Id>
<CompanyId>Wall Mart</CompanyId>
<Created>2010-08-24T22:47:44.177Z</Created>
<IsDeleted>false</IsDeleted>
</Table>
</Party>

 

 

Compose XML.PNG

 

 

Initialize variables

We init the variables for both arrays. (ID and CompanyID)

Initialize variables.PNG

 

 

Run XML through the xPath functions

We run the formula using an xPath function to target each tag.

 

xpath(xml(outputs('Compose')),'/Party/Table/Id')
xpath(xml(outputs('Compose')),'/Party/Table/CompanyId')

 

 

xPath.PNG

 

Apply the output to each array & remove tags

We take the output from the previous steps and assign each data point to an array index. We also remove tags here using replace

 

 

replace(replace(decodeBase64(item()?['$content']),'<Id>',''),'</Id>','')
replace(replace(decodeBase64(item()?['$content']),'<CompanyId>',''),'</CompanyId>','')

 

 

Apply to array.PNG

 

 

Compose 

We take the data from each Apply to Each and compose it to a variable.

 

compose array.PNG

 

 

Apply to each / Create SharePoint Item in List

We perform an Apply to Each, bring in the composed variable, and assign it to a single field. This is where I cannot assign the Company ID data to a column on this list.

apply to list.PNG

 

Here I can apply the array as an output, but not loop through the array to apply each data point to a column. How can this be accomplished?

 

 

Final result

As you can see, each XML ID can through into each row. However, since I can't do another Apply to Each from the Company ID output, I cannot loop through the array. 

 

result.PNG

 

Thank you for any help in advance! Please let me know if I can provide any additional details.

1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

 

Hi @Anonymous ,

 

It seems that you have posted a similar question here:

https://powerusers.microsoft.com/t5/Building-Flows/Apply-to-Each-action-SP-Create-Item-Only-allows-for-one-input/m-p/549916

 

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

1 REPLY 1
v-bacao-msft
Community Support
Community Support

 

Hi @Anonymous ,

 

It seems that you have posted a similar question here:

https://powerusers.microsoft.com/t5/Building-Flows/Apply-to-Each-action-SP-Create-Item-Only-allows-for-one-input/m-p/549916

 

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.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (6,318)