Table of contents
The basics and the structure
Just like JSON, XML describes information or represents data. More on XML here: https://www.w3schools.com/xml/default.asp Power Automate supports all XMLs in Version 1.
Official links:
- https://learn.microsoft.com/en-us/azure/logic-apps/expression-functions-reference#xpath
- https://learn.microsoft.com/en-us/azure/logic-apps/expression-functions-reference#xml
XML Schema
Overall XML follows this syntax:
<root>
<child>
<subchild>.....</subchild>
</child>
</root>To write a valid XML schema, you need to follow some rules:
- The XML can start with a prolog, but this is optional
<?xml version="1.0" encoding="UTF-8"?>- Just like JSON the names of the roots or childs can vary on your use case. In the example on the right, the root element is bookstore and the next child is book. In one XML document you might even find multiple different structures for different data.
- Every XML document must have a root element (bookstore)
- XML elements must have a closing tag (message and /message)
<message>This is correct</message>- XML tags are case sensitive
- XML attribute values must be quoted (e.g. book category=āwebā)
Example XML

Reading data from a XML document in Power Automate
Before you try to parse XML in Power Automate, you should always use the expression xml() to format a stringifiedā XML document into readable xml. Then you use the expression xpath() to navigate through the XML document.
Reading simple XML documents
I would describe a simple XML document as a single entity information or anything that is not a list. The EmployeeProfile is the returned data from an API
Reading the Employee Id value: EMP-1001
string() lets us read the value of the element that we have built the path for.
xpath(xml(outputs('Compose_-_XML_simple')), 'string(/EmployeeProfile/EmployeeId)')Reading the Department value: IT
xpath(xml(outputs('Compose_-_XML_simple')), 'string(/EmployeeProfile/Department)')Reading the currency attribute value of the salary
@ in front of the attributes name is needed to get the value of an attribute.
xpath(xml(outputs('Compose_-_XML_simple')), 'string(/EmployeeProfile/Salary/@currency)')In my example the XML document is stored in an compose action called āCompose - xml simpleā.

Example XML
Using only one slash to navigate along a path, tells the xpath() an absolute path. Using double slashs allows the xpath() to freely the element from within the complete xml document. This might lead to confusing if a elements name is reused.
Reading list type XML documents
List type XML documents can be the equivalent of JSON arrays - they are a list of information. In my example the XML document is stored in an compose action called āCompose - xml advancedā.

Transforming a XML list into an JSON array
Yes, you can transform a XML list into a cleaner JSON array by using the select action. It requires you to manually map out each element and its value. You can have AI do it with all elements when you give it one example.
From: xpath(
xml(outputs('Compose_-_xml_advanced')),
'/Employees/EmployeeProfile'
)
Map Left: EmployeeId
Map Right: xpath(item(),'string(/EmployeeProfile/EmployeeId)')As an expression for from, we use the Employees node. It basically already looks like an JSON array. We then map the elements name to its value by using the already know item() syntax. We only add the part that reads the current items EmployeeId using string().
In Power Automate it looks like this:

The raw outputs of the select action show this result:

Lets add the salary and currency to our select action. We always want to apply the correct data type for our information. This mean that the salary should be an integer value in our array.
For the salary you can either wrap the xpath() expression with int() or float(). Either expression works and should be picked based on your use case.
From: xpath(
xml(outputs('Compose_-_xml_advanced')),
'/Employees/EmployeeProfile'
)
Map Left: Salary
Map Right: float(xpath(item(),'string(/EmployeeProfile/Salary)'))For the currency:
From: xpath(
xml(outputs('Compose_-_xml_advanced')),
'/Employees/EmployeeProfile'
)
Map Left: Currency
Map Right: xpath(item(),'string(/EmployeeProfile/Salary/@currency)')In Power Automate it looks like this:

The raw outputs of the select action show this result:

Afterwards, any filtering, sorting or looping can than be done using basic Power Automate features.
Further examples
Summing up an array of numbers
In this example I wanted to sum up all the meeting durations for one day from my outlook calendar. I used a select action to return the duration in hours, then a compose action to transform into a json array. Then that array gets transformed using xpath where the numbers are summed up.
//Select action
div(
float(
sub(
ticks(item()?['end']),ticks(item()?['start'])
)
),36000000000
)
//Compose action 1
{
"root": {
"Numbers": body('Select')
}
}
//Compose action 2 - result is the summed numbers
xpath(xml(outputs('Compose_-_1')), 'sum(/root/Numbers)')Changelog
Date | Changes |
03.03.2026 | Initial version |
ā¤ļøĀ Thanks for reading.