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

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
Highlighted
Community Support
Community Support

Re: Ingest XML to SharePoint list with Power Automate and xPath

 

Hi @Tyler_ ,

 

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

 

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
Highlighted
Community Support
Community Support

Re: Ingest XML to SharePoint list with Power Automate and xPath

 

Hi @Tyler_ ,

 

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

 

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

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (6,578)