Home > Software design >  Comcatenate multiple XML files
Comcatenate multiple XML files

Time:09-29

I have more than 1 XML file in my azure BLOB storage account which all have the same format, is it possible to use Logic App to concatenate them all into a single XML file? I've tried using using concat but it exceeds the limit of 104,857,600 characters, so I'll really need to append to the existing BLOB file but I only seem to have the option to create/update which both overwrite it.

For example, file 1 could look like this:

<?xml version="1.0" encoding="utf-8"?>
<enfinity xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex catalog.xsd http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt dt.xsd" major="6" minor="1" family="enfinity" branch="enterprise" build="build" xmlns="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt">
  <offer sku="123456777">
    <custom-attributes>
      <custom-attribute name="parentcolour" dt:dt="string" xml:lang="en-US">Green</custom-attribute>
      <custom-attribute name="parentcolour" dt:dt="string" xml:lang="de-DE">Grün</custom-attribute>
    </custom-attributes>
  </offer>
</enfinity>

Whereas file 2 could look like this:

<?xml version="1.0" encoding="utf-8"?>
<enfinity xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex catalog.xsd http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt dt.xsd" major="6" minor="1" family="enfinity" branch="enterprise" build="build" xmlns="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt">
  <offer sku="123456">
    <variations>
      <mastered-products>
        <mastered-product sku="123456777" domain="WhiteStuff-MasterRepository"/>
        <mastered-product sku="123456888" domain="WhiteStuff-MasterRepository"/>
      </mastered-products>
    </variations>
  </offer>
</enfinity>

I know one has <custom-attributes> and the other has <variations>, but it's the <offer sku=> block which need to be appended so overall the file would look like this:

<?xml version="1.0" encoding="utf-8"?>
<enfinity xsi:schemaLocation="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex catalog.xsd http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt dt.xsd" major="6" minor="1" family="enfinity" branch="enterprise" build="build" xmlns="http://www.intershop.com/xml/ns/enfinity/7.0/xcs/impex" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dt="http://www.intershop.com/xml/ns/enfinity/6.5/core/impex-dt">
  <offer sku="123456777">
    <custom-attributes>
      <custom-attribute name="parentcolour" dt:dt="string" xml:lang="en-US">Green</custom-attribute>
      <custom-attribute name="parentcolour" dt:dt="string" xml:lang="de-DE">Grün</custom-attribute>
    </custom-attributes>
  </offer>
  <offer sku="123456">
    <variations>
      <mastered-products>
        <mastered-product sku="123456777" domain="WhiteStuff-MasterRepository"/>
        <mastered-product sku="123456888" domain="WhiteStuff-MasterRepository"/>
      </mastered-products>
    </variations>
  </offer>
</enfinity>

If it helps, the SKU appearing in one file will never appear in a separate file.

CodePudding user response:

Based on your shared requirement I have reproduced the same and this is how it worked for me :

I have retrieved the blob from storage > Added Compose Connector with json function > then parse it into json > Then merged into one by using Customised json and add the values accordingly

Here is the Screenshot of the flow for your reference: enter image description here

enter image description here

enter image description here

At last you need to convert the variable to XML again inorder to get your required format

REFERENCES: azure functions - Merge multiple XML files of same structure into single xml in logic apps - Stack Overflow

  • Related