In this Power Automate tutorial, we will see how to convert XML to JSON using Power Automate.
For example, we will convert the XML code to JSON using Power Automate, like below. Then we will send the JSON data via email by parsing it.
For this, we will create an Instant cloud flow that will trigger manually, taking the user input as an XML file (containing product details) and converting content from base 64 to string using Power Automate. After that, we will convert XML to JSON using JSON().
Once it is converted, we will parse the JSON, create an HTML table, and email the recipients.
How to convert XML to JSON using Power Automate
Here we will see an example of how to convert XML files to JSON using Power Automate.
Step 1: Log in to Power Automate, then click on +Create -> select Instant cloud flow.
Then provide the flow name and select Manually trigger a flow action. Then click on Create.
Now, you can see the Manually trigger a flow action is added to the flow page. Now expand the action -> click on Add an input ->select File inputs.
Step 2: Now we will convert the base64 to string using Power Automate, so, click on the +New step -> select Compose action. Then provide the below information:
- Inputs: Provide the below expression:
base64ToString(triggerBody()['file']['contentBytes'])
Step 3: Now we will convert XML string to JSON using Power Automate, so click on the +New step -> select Compose action. Then provide the below information:
- Inputs: Provide the below expressions:
json(xml(outputs('Compose_-_base_64_to_string')))
Step 4: Now we will parse the JSON, so click on the +New step and select Parse JSON action. Then provide the below information:
- Content: Select the output of the above compose action from dynamic content.
- Schema. To get the schema, click on the Generate from sample button and provide the output of the above compose action. Then click on Done.
Step 5: After that, we will create html table, so click on the +New step -> select Create HTML table action. Then provide the below information:
- From: Select the product from the dynamic content.
Step 6: At last, we will send an email with the above Html table, so click on the +New step -> select Send an email (V2) action. Then provide the below information:
- To: Provide the email id whom you want to send an email
- Subject: Provide the subject of an email.
- Body: Select the output -Create Html table action from dynamic content.
Step 7: Now run the flow manually; for this, save the flow, click on the Test icon -> select the Manually option -> click on the Test button. Then click Import and select the XML file -> click on the Run flow button. You can see your flow run successfully.
Now go to Outlook; you can see the email will look like below:
This is an example of how to convert XML files to JSON using Power Automate.
Conclusion
In this Power Automate tutorial, we saw how to convert XML files to JSON using Power Automate.
You may like the following tutorials:
- Create a Word Document from HTML using Power Automate
- Update SharePoint List Field with today’s date in Power Automate
- How to Apply Filter Between Dates in Power Automate?
- How to Convert XML to Array in Power Automate?
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com