Reputation: 60691
Is it possible to do a coalesce against 2 records having the same schema?
Suppose I have 2 payloads such as:
<Person>
<Color></Color>
<First>Joe</First
<Last>Smith</Last>
<Date>1/1/2019</Date>
</Person>
And this one:
<Person>
<Color>Blue</Color>
<First></First
<Last>Smith</Last>
<Date></Date>
</Person>
Expected result:
<Person>
<Color>Blue</Color>
<First>Joe</First
<Last>Smith</Last>
<Date>1/1/2019</Date>
</Person>
How do we always take the non-empty value for a specific node?
Upvotes: 0
Views: 213
Reputation: 15724
You can transform your xml to json and use "If" condition in logic app to coalesce the two xml file. Below is the whole screenshot of my logic app.
Details:
First I upload the two xml files to azure storage blob and get them in logic app by "Get blob content" action. Then I initialize a variable named "jsonPersonString1" and use the expression to transform the blob content to json, then use "Parse JSON" action to parse it.(I post the screenshot below)
Second please do same steps as above to transform the second xml file to json and parse it.(also post the screenshot below)
Then I initialize variable named "result" and set its value as null.
After that, create a "If" condition to judge which value we should use and set the outputs to the variable "result". Here I just do the operation for the property "Color", you can also do same operation for other properties.
After complete the "If" condition, we can transform the json to xml.
Hope it would be helpful to your problem~
Upvotes: 1