How to remove all tabs and break lines of XML file in data factory?

Vieira Dias, Leonor 20 Reputation points
2023-08-15T14:55:41.63+00:00

Hello,

I have an XML file and would like to combine all the lines of code into a single one. Manually, this is the equivalent of placing your mouse at the end of each line and pressing "delete" to join the next line to the current one. I tried using the Derived Column but it does not apply since I do not have columns and the file comes from the user therefore it will be different every time.

Once everything is combined in a single line, I want to find every time the word "name" appears and break the line there.

Example input:

<animals>
    <animal>
        <name>Lion</name>
        <species>Panthera leo</species>
        <habitat>Savannah</habitat>
    </animal>
    <animal>
        <name>Elephant</name>
        <species>Loxodonta africana</species>
        <habitat>African Plains</habitat>
    </animal>
    <animal>
        <name>Tiger</name>
        <species>Panthera tigris</species>
        <habitat>Forest</habitat>
    </animal>
</animals>

Output first stage:

<animals><animal><name>Lion</name><species>Panthera leo</species><habitat>Savannah</habitat></animal><animal><name>Elephant</name><species>Loxodonta africana</species><habitat>African Plains</habitat></animal><animal><name>Tiger</name><species>Panthera tigris</species><habitat>Forest</habitat></animal></animals>

Final output

<animals><animal>
<name>Lion</name><species>Panthera leo</species><habitat>Savannah</habitat></animal><animal>
<name>Elephant</name><species>Loxodonta africana</species><habitat>African Plains</habitat></animal><animal>
<name>Tiger</name><species>Panthera tigris</species><habitat>Forest</habitat></animal></animals>
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
Developer technologies | XAML
Developer technologies | XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.