首页 > 解决方案 > 连接多个 XML 文件

问题描述

我的 azure BLOB 存储帐户中有超过 1 个 XML 文件,它们都具有相同的格式,是否可以使用 Logic App 将它们全部连接成一个 XML 文件?我试过使用 concat 但它超过了 104,857,600 个字符的限制,所以我真的需要附加到现有的 BLOB 文件,但我似乎只有创建/更新的选项,它们都覆盖它。

例如,文件 1 可能如下所示:

<?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>

而文件 2 可能如下所示:

<?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>

我知道一个有<custom-attributes>,另一个有<variations>,但它是<offer sku=>需要附加的块,所以整体文件看起来像这样:

<?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>

如果有帮助,出现在一个文件中的 SKU 将永远不会出现在单独的文件中。

标签: xmlazure-logic-apps

解决方案


根据您的共同要求,我复制了相同的内容,这就是它对我的工作方式:

我已经从存储中检索了 blob > 添加了带有 json 函数的 Compose 连接器 > 然后将其解析为 json > 然后使用自定义 json 合并为一个并相应地添加值

这是流程的屏幕截图供您参考: 在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

最后,您需要再次将变量转换为 XML 以获得所需的格式

参考: 天蓝色函数 - 将多个相同结构的 XML 文件合并到逻辑应用程序中的单个 xml 中 - 代码日志


推荐阅读