Search code examples
azureazure-functionsazure-logic-appsazure-data-factoryazure-databricks

How to convert xml data into csv/excel/table in Azure


we need to convert XML data into csv/excel/table in Azure cloud.

below is the sample xml code.

<SOAP-ENV:Envelope
   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">

<SOAP-ENV:Body>
           <ns2:getProjectsResponse
               xmlns:ns2="http://www.logic8.com/eq/webservices/generated">
               <ns2:Project>
                   <ns2:fileName>P10001</ns2:fileName>
                   <ns2:alias>project1</ns2:alias>
               </ns2:Project>
               <ns2:Project>
                   <ns2:fileName>P10002</ns2:fileName>
                   <ns2:alias>project2</ns2:alias>
               </ns2:Project>
       <ns2:Project>
                   <ns2:fileName>P10003</ns2:fileName>
                   <ns2:alias>project3</ns2:alias>
               </ns2:Project>
           </ns2:getProjectsResponse>
       </SOAP-ENV:Body>
   </SOAP-ENV:Envelope>

Expected output:

output

Can anyone help me on this.


Solution

  • You could try this way, firstly convert xml to json then use create csv table action to implement it. The below is my test flow.

    enter image description here

    I use blob to get the xml content. The Compose action input is json(xml(body('Get_blob_content'))), then will get thejson data. Then is the Create CSV table From, ause the from data should be array, so it should be outputs('Compose')['SOAP-ENV:Envelope']['SOAP-ENV:Body']['ns2:getProjectsResponse']['ns2:Project'].

    The last thing is customize the header and the value, the ProjectID value should be item()['ns2:fileName'] and the ProjectDescription should be item()['ns2:alias'].

    And here is the flow output, suppose this is what you want, hope this could help you.

    enter image description here