Welcome again to another Logic Apps Best Practices, Tips, and Tricks. In my previous blog posts, I discussed some of the essential best practices to follow when working with Azure Logic Apps. Check out these Logic App tips and tricks!
Today I will speak about another important Best practice, Tips, and Tricks that you need to consider while designing your business processes (Logic Apps): How to debatching XML messages.

📝 One-Minute Brief
You can debatch XML content in Logic Apps similarly to JSON inputs. However, to achieve that, you need to use a developer trick.
Here you will learn how to accomplish this functionality.
#46 Debatching XML Messages
Previously, we saw how simple it is debatching or split JSON messages inside Logic Apps. We even did a Friday fact about this, but things have changed, and what we could do in the past is now a little bit different. Logic Apps are built on APIs, natively supporting JSON messages. Therefore, it is pretty easy to implement this pattern; however, the main question is: Can we still also achieve this using old-school integration with XML messages?
And the answer to that question is yes. Yes, you can debatch XML content in Logic Apps similarly to JSON inputs. However, to achieve that, you need to use a developer trick. A developer trick that we will be addressing on this blog post, so let’s walk you through the process using a sample XML structure. For example, consider the following XML content that we want to debatch:
<People>
<Person>
<name>Sandro Pereira</name>
</Person>
<Person>
<name>Luis Rigueira</name>
</Person>
</People>
To accomplish this inside Logic App, let’s start by adding:
- A Request > When a HTTP request is received trigger to your Logic App to handle incoming HTTP requests.

Because, by default, the When a HTTP request is received trigger doesn’t support XML Schemas, there is no way for the designer to know that there is a repeating structure in which you can split the incoming message. For this reason, the Split On option is not available for configuration.

So, to accomplish the same concept using XML Messages, we need to apply the following trick:
- Switch to the Code View of your Logic App. This allows you to directly edit the JSON definition of your Logic App (always be careful when working in the code view).

- In the triggers section of your Logic App definition, add the following line to enable debatching:
"splitOn": "@xpath(xml(triggerBody()), '/*[local-name()=\"People\"]/*[local-name()=\"Person\"]')"

- Explanation of the splitOn Property:
- This line specifies that the splitOn feature is enabled and defines where the split should occur. In this case, it uses the following XPath expression:
- /*[local-name()=\”People\”]/*[local-name()=\”Person\”]
- Breakdown of the XPath
- Root Element: People
- Use /[local-name()=”People”] to target the People element regardless of namespace.
- Child Elements: Person
- Use /[local-name()=”Person”] to target each Person element within People.
- Root Element: People
- This line specifies that the splitOn feature is enabled and defines where the split should occur. In this case, it uses the following XPath expression:
- Finally, get back into the Designer

- Click on the When a HTTP request is received trigger. On the properties panel you will see a warning:
- Failed to evaluate outputs because splitOn @xpath(xml(triggerBody()), ‘/*[local-name()=”People”]/*[local-name()=”Person”]’) cannot be evaluated. As a result, this operation’s outputs might not be correctly visible in subsequent actions .
- On the Settings panel, unfortunately, you will not be able to see whether the splitOn property is enabled or configured; however, the split XPath expression will be active and performing the intended debatching action.
- As you can see in the run history picture below, the first execution will have Sandro record:

- And the second will have Rigueira’s record:

I confess, it is not perfect; we should have a better user experience. The UI should reflect the splitOn property once it is set up in the code view, because in the past, that was possible:

But at least, the functionality works.
If you want to know more about Logic Apps Best practices, Tips and Tricks, you can download my handbook for free: The Ultimate Azure Logic Apps Handbook: 50 Expert Tips & Best Practices.
I hope you find this helpful! If you liked the content or found it useful and want to help me write more, you can consider buying (or helping to buy) my son a Star Wars Lego set.