Transform XML in a Logic App
Transform XML in a Logic App
Get XSD files of your XML files
<?xml version="1.0" encoding="utf-8"?><products><product><itemId>ABC123</itemId><itemName>ABC 123</itemName><price>1</price><unit>pcs</unit></product></products>
<?xml version="1.0" encoding="utf-8"?><varer><vare><vareNummer>ABC123</vareNummer><vareNavn>ABC 123</vareNavn><pris>1</pris><enhet>pcs</enhet></vare></varer>
- Get your from XSD and save it to a file with the extension .xsd.
- Get your to XSD and save it with the extension .xsd.
Create a Map (Visual Biz talk XSLT)
- Create a Integration account project in Visual Studio
- Add your to and from XSD files to the project
- Add a new item of type Map
- Double click the map you just created
- In the from section add the from XSD
- In the to section add the to XSD
- drag and drop the mappings in the fields
- When done build the project to produce the XSLT file, located in bin/debug/ folder.
Create an Integration account
- Same resource group and location as your logic app and wait for it to deploy
- Open the resource and choose maps from the left most menu under Settings
- Upload your XSLT file
- Choose the Schemas menu option from the left
- Upload your XSD to schema, the resulting XML structure.
Create a logic app transforming XML
- Create a new logic app
- Same resource group and location as your integration account
- Go to Settings --> Workflow settings
- Specify the integration account you just added
- Add whichever trigger you want to start
- Add XML transform Action
- Add your from XML in the Content field
- Choose your Map (from the Integration Account your just created)
- Add XML validation action
- Content: "Transformed XML"
- Schema name: your to XSD you uploaded to the integration account
- Run your logic app to see the results.
In my example I entered this XML structure:
<?xml version="1.0" encoding="utf-8"?>
<products>
<product>
<itemId>ABC123</itemId>
<itemName>ABC 123</itemName>
<price>1</price>
<unit>pcs</unit>
</product>
<product>
<itemId>DEF123</itemId>
<itemName>DEF 123</itemName>
<price>2</price>
<unit>pcs</unit>
</product>
<product>
<itemId>GHI123</itemId>
<itemName>GHI 123</itemName>
<price>3</price>
<unit>pcs</unit>
</product>
<product>
<itemId>JKL123</itemId>
<itemName>JKL 123</itemName>
<price>4</price>
<unit>ltr</unit>
</product>
</products>
The logic app transformed the XML to this:
<?xml version="1.0" encoding="utf-8"?>
<varer>
<vare>
<vareNummer>ABC123</vareNummer>
<vareNavn>ABC 123</vareNavn>
<pris>1</pris>
<enhet>pcs</enhet>
</vare>
<vare>
<vareNummer>DEF123</vareNummer>
<vareNavn>DEF 123</vareNavn>
<pris>2</pris>
<enhet>pcs</enhet>
</vare>
<vare>
<vareNummer>GHI123</vareNummer>
<vareNavn>GHI 123</vareNavn>
<pris>3</pris>
<enhet>pcs</enhet>
</vare>
<vare>
<vareNummer>JKL123</vareNummer>
<vareNavn>JKL 123</vareNavn>
<pris>4</pris>
<enhet>ltr</enhet>
</vare>
</varer>
Comments
Post a Comment