cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bouillons
Resolver I
Resolver I

How to get sharepoint list items as xml ?

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

5 REPLIES 5
mahoneypat
Super User
Super User

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

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


bouillons
Resolver I
Resolver I

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
Resolver I
Resolver I

The expression I'm using is 

xpath(outputs('Compose_2'),'string(//*[name()="Tel"][1])')
and I'm getting back a blank string
bouillons
Resolver I
Resolver I

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
Super User
Super User

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

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.

Users online (1,203)