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 Platform Community / Forums / Power Automate / How to get sharepoint ...
Power Automate
Answered

How to get sharepoint list items as xml ?

(0) ShareShare
ReportReport
Posted on by 302

Hi,

 

When I use get items from a sharepoint list, it returns the data in json format. Is there a way to get the data in xml instead, or an easy and fast way to convert the json result to an xml string ?

 

Stephane

Categories:
  • Verified answer
    mahoneypat Profile Picture
    1,720 on at

    The SharePoint REST API returns data as XML by default.  Below is an example.  Choose your site from the picklist and then enter the text shown and substitute in your list name (in place of ButtonList).  Also put the shown header for Accept to get an XML response.  Then use a Compose to extract the $content from the response and convert it to a string (see expression in Note of Compose step).

     

    Working with lists and list items with REST | Microsoft Docs

     

    mahoneypat_0-1637884595315.png

     

    Pat

     

  • bouillons Profile Picture
    302 on at

    Thanks Pat !

     

    I'm able to get the xml of the list, but my ultimate goal is to extract an item using xpath.

    So, the first thing I did was convert the output of base64tostring function using xml(base64...)

    Next I'm trying to get an item from the xml using an xpath, but it doesn't seem to work. I'm trying to extract the value of the Tel field for the first item.

    bouillons_0-1637950620150.png

     

  • bouillons Profile Picture
    302 on at

    The expression I'm using is 

    xpath(outputs('Compose_2'),'string(//*[name()="Tel"][1])')
    and I'm getting back a blank string
  • bouillons Profile Picture
    302 on at

    Using the below expression in the xpath tester at http://xpather.com gives me the correct result:

     

    //m:properties[starts-with(d:Title,'0002')]/d:Tel

     

    but entering this expression in the xpath(outputs('Compose_2'),'//m:properties[starts-with(d:Title,"0002")]/d:Tel')) gives an error

  • mahoneypat Profile Picture
    1,720 on at

    Why not just return the data as JSON instead of XML to greatly simplify things?

    Pat

     

  • bouillons Profile Picture
    302 on at

    I prefer to work with xml as it is soooo much faster than using apply for each. Unfortunately, xpath seems to balk at xml containing namespaces, at least, that's what I suspect. When I use a namespaceless xml, the xpath queries work as expected.

  • mahoneypat Profile Picture
    1,720 on at

    Since you are pulling out a specific field, have you tried to use a Select action instead of an Apply to each.  Would be much faster.

    Pat

     

  • bouillons Profile Picture
    302 on at

    Thanks, my scenario is that I want to combine the data of two or more lists that share a common field. I am already using select, but I can only give one array as input and I need to pull in a field from the other array where list1.CommonField is equal to list2.CommonField.

    I have not found how to do that in a standard select, but I achieved the desired result using xpath, so my performance has gone from minutes to seconds.

     

    If I could just natively use the xml returned by the sharepoint API, that would be even faster than using the Get Items first and converting that to Xml. There, I'm still stuck with the xpath syntax that seems to balk on the namespaces. I opened another community thread for that specifically.

     

    Thanks for your time and effort Pat, greatly appreciated !

  • mahoneypat Profile Picture
    1,720 on at

    Ok. Please see this solution on how to filter one array for those that exist (or not) in another.

    Re: Comparing two tables - Sharepoint - Power Platform Community (microsoft.com)

     

    Pat

     

  • WG3 Profile Picture
    19 on at

    Questions @mahoneypat@bouillons, how do you return JSON instead of XML?

    How should the example URL for instead be be changed? https://X.sharepoint.com/sites/A/_api/web/lists/getbytitle('B')/items

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 275 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 235

#3
David_MA Profile Picture

David_MA 178 Super User 2026 Season 2

Last 30 days Overall leaderboard