Power Automate Xml Function Explained

Power Automate Xml Function

The Power Automate Xml function lets you convert JSON to XML in Power Automate flow. Just pass a string of a JSON object to the xml function and retrieve the equivalent XML representation for the given JSON object.

In this article, I’ll introduce you to the xml function and will provide a step-by-step guide on how to use the function in a Microsoft flow.

Power Automate Xml Function

power automate xml function
xml function in Power Automate

Convert a string containing a JSON object to its corresponding XML version.



Input parameters

  • value (mandatory): The input should be a string containing a JSON object, which should have only one top-level property and cannot be an array. The backslash (\) should be used as an escape character for double quotation marks (“) within the JSON object.

Return value

  • Returns the XML for the given JSON object.

Power Automate Xml Example

xml(json('{ "name": "John Doe" }'))

=> <name>John Doe</name>

How To Convert JSON To XML With The Power Automate Xml Function

In this little example we convert a JSON string to XML in Power Automate.

We will be using the following JSON.

      "name": "John Doe",
      "email": "[email protected]"

The equivalent XML generated by the Power Automate Xml function should look like this.

    <name>John Doe</name>
    <email>[email protected]</email>

Follow the steps to convert the JSON to XML in a Power Automate flow by using the xml function in an expression.

  1. Create a new flow with trigger ‘Manually trigger a flow’

    Power Automate Xml create new flow

    New flow

  2. Add a new step by clicking on ‘+ New step’

    Power Automate Xml create new step

    New step

  3. Filter for ‘initialize’ and click on the ‘Initialize variable’ action

    Power Automate Xml add initialize variable

    Add Initialize variable action

  4. Setup Initialize variable action: 1) set a name, 2) set type to Object and paste the JSON from the top of the article into Value

    Power Automate Xml setup initialize variable

    Setup Initialize variable action

  5. Add a new compose step by filtering for ‘compose’ and by clicking on the ‘Compose’ action

    Power Automate Xml add compose

    Add a compose action

  6. Setup compose 1) click into inputs (popup comes up), 2) click on ‘Expression’, 3) set the function to ‘xml(variables(‘json’))’, 4) click on OK

    Power Automate Xml setup compose

    Setup compose with the Power Automate xml expression

  7. Do a test run

    Power Automate Xml test run

    Result – Power Automate convert JSON to XML

Leave a Comment

Your email address will not be published. Required fields are marked *