First of all, why would we need to encode xml? Sometimes characters in the xml could cause problems when you use them in an actions. Encoding characters can then typically solve this issue.
Typically you would treat the tags in xml differently from the actual data. In the example below. We would potentially want to encode the the ‘data with a space’ tag.
<xml><data with a space>Some data that I have here & some more 'data'</data with a space><xml>
So what does Power Automate offer us.
Within recent Logic Apps release notes I found the functions mentioned earlier. And as Power Automate is built on Logic Apps these functions should work in Power Automate too.
Example Xml
In my examples below I’ve created a flow that has a Compose step with some xml. I’ve renamed this Compose step to MyXml.
4 new undocumented functions to encode and decode Xml in Power Automate 1
EncodeXmlValue
Then within Power Automate I’m adding another Compose action with the following expression
EncodeXmlValue(outputs('MyXml'))
4 new undocumented functions to encode and decode Xml in Power Automate 2
I now get the following result
4 new undocumented functions to encode and decode Xml in Power Automate 3
DecodeXmlValue
And then when we decode the above output we will get out original xml data back.
DecodeXmlValue(outputs('EncodeXmlValue'))
4 new undocumented functions to encode and decode Xml in Power Automate 4
EncodeXmlName
As mentioned earlier, there is a second method of encoding available within Xml. You might recognise this from URL in your browsers as well. Typically URLs in browsers will use the same escape characters as these 4 function use.
EncodeXmlName(outputs('MyXml'))
4 new undocumented functions to encode and decode Xml in Power Automate 5
DecodeXmlName
Then finally we can decode using the DecodeXmlName function.
DecodeXmlName(outputs('EncodeXmlName'))
4 new undocumented functions to encode and decode Xml in Power Automate 6
Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like.
I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide.
For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions.
SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/
Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/
You can contact me using contact@sharepains.com
Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like.
I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide.
For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions.
SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/
Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/
You can contact me using contact@sharepains.com
Hi Pieter, thanks for sharing.
By the way, my personal sharepain is that your site is starting to be a bit to much advertorial to be pleasant to open and browse
Hi Marcel, thank you for your comment. The ads are simply covering my costs. Yes, it is not ideal, but what would the alternative be? I can pick up the costs myself so that I can help others or create paid for content. I don’t like either of these options. The small pain of ads sitting in the way I have just accepted.
Very useful thanks! I could have done with knowing this in a recent project.
Hi Pieter, thanks for sharing.
By the way, my personal sharepain is that your site is starting to be a bit to much advertorial to be pleasant to open and browse
Hi Marcel, thank you for your comment. The ads are simply covering my costs. Yes, it is not ideal, but what would the alternative be? I can pick up the costs myself so that I can help others or create paid for content. I don’t like either of these options. The small pain of ads sitting in the way I have just accepted.