Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
528 views
in Technique[技术] by (71.8m points)

How to transform xml data to csv on Azure logic app

I am trying to grab the XML from the URI below and transform it into a csv file. How do I go about doing this with an Azure Logic app?

https://reportservices.crediblebh.com/reports/ExportService.asmx/ExportXML?connection=Y!KcFwIoIa1BZLzJnKfEshACoW10Rtw!DmvWxFkFgsUiJmP34wHKBMB9VD1YcnuRPQewAfLGSdDOiQXdvGiURA__&start_date=&end_date=&custom_param1=&custom_param2=&custom_param3=

Step 1 in my Logic app is a HTTP trigger using the GET method:

HTTP trigger with GET method and URI containing the XML I want to parse

When I run Step 1 I get the following:

Result after running Step 1

Essentially I want to parse the Body of of the HTTP trigger (Step 1) into a csv file. In other words I want to transform this:

<?xml version="1.0" encoding="utf-8"?>
<string xmlns="https://www.crediblebh.com/">&lt;NewDataSet&gt;
  &lt;Table&gt;
    &lt;client_id&gt;-99999&lt;/client_id&gt;
    &lt;clientprogramscount&gt;80066&lt;/clientprogramscount&gt;
    &lt;teamclientcount&gt;68247&lt;/teamclientcount&gt;
    &lt;employeeclientscount&gt;40415&lt;/employeeclientscount&gt;
    &lt;questioncount&gt;190954&lt;/questioncount&gt;
    &lt;answercount&gt;463010&lt;/answercount&gt;
    &lt;delvisitcount&gt;7484&lt;/delvisitcount&gt;
    &lt;savedvisitanswercount&gt;6950104&lt;/savedvisitanswercount&gt;
    &lt;cntclientsext&gt;60330&lt;/cntclientsext&gt;
    &lt;cntclientepisode&gt;68069&lt;/cntclientepisode&gt;
    &lt;cntclientvisit&gt;487500&lt;/cntclientvisit&gt;
    &lt;cntchangelog&gt;13231067&lt;/cntchangelog&gt;
    &lt;cntchangelogdetail&gt;1272642&lt;/cntchangelogdetail&gt;
    &lt;cntclientvisitapproval&gt;29540&lt;/cntclientvisitapproval&gt;
  &lt;/Table&gt;
&lt;/NewDataSet&gt;</string>

into the following csv:

client_id,clientprogramscount,teamclientcount,employeeclientscount,questioncount,answercount,delvisitcount,savedvisitanswercount,cntclientsext,cntclientepisode,cntclientvisit,cntchangelog,cntchangelog,cntchangelogdetail,cntclientvisitapproval -99999,80066,68247,40415,190954,463010,7484,6950104,60330,68069,487500,13231067,13231067,1272642,29540

Sorry that I can't show the actual images in my post because apparently I don't have enough reputation points to embed actual images yet.

Thanks in advance for your help!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You many want to use "Flat File Encoding" action in Logic App.

For this, you should create a schema, which would map the XML fields into CSV format that you require -> place that schema in Integration Account -> use this schema in "Flat File Encoding" action in Logic App to transform XML data to CSV format. Take a look at this Encode and decode flat files in Azure Logic Apps by using the Enterprise Integration Pack

If Integration Account option seems expensive, use a custom Azure Function that does the schema functioning (XML->CSV) and use Azure Function action in Logic App.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...