在逻辑应用程序中将多个具有相同结构的 XML 文件合并为单个 xml

2024-06-20

  1. 从 FTP 服务器位置,我的逻辑应用程序正在获取可以容器的 zip 文件夹包含“N”号。示例结构的 xml 文件

  2. 我可以通过将 xml 文件解析为 JSON 来读取 for-each 循环中的内容

3. 现在,我希望我的逻辑应用程序将 JSON 中的多个 xml 文件合并到单个 xml 文件中

请建议我如何实现上述第 3 点。 我有集成帐户来存储映射文件。

输入文件 1:-

 <?xml version="1.0"?>
<orderQuote>
    <order_id>AZS000001</order_id>
    <user_request>
        <app_user>
            <username>varunxxxxxxxxxxxx</username>
            <user_first_name>Varun</user_first_name>
            <user_last_name>Thakur</user_last_name>
            <user_email>[email protected] /cdn-cgi/l/email-protection</user_email>          
        </app_user>

    </user_request>

    <quote_id>345678</quote_id>
    <rate_id>ABC001</rate_id>
  <contract_id>SR_ABC_XYZ</contract_id>
    <amendment_id>2019062401</amendment_id>
    <price> 10</price>
  <rate_effective_date>01-Jul-2019</rate_effective_date>
    <rate_expiration_date>30-Sep-2019</rate_expiration_date>
    <origin_trade></origin_trade>
    <destination_trade></destination_trade>
    <origin_city>Haiphong</origin_city>
    <origin_country>VIETNAM</origin_country>
    <destination_city>Atlanta</destination_city>
    <destination_country>USA</destination_country>
    <ordermentType>XYZ</ordermentType>
    <ordermentSize>XYZ</ordermentSize>
    <ordermentSizeType>DC</ordermentSizeType>
    <currency>USD</currency>
    <order_dt>17-Sep-2019</order_dt>
    <customer>CompanyName RM Team</customer>
    <quote_creation_dt>17-Sep-2019</quote_creation_dt>

</orderQuote>

输入文件 2:-

 <?xml version="1.0"?>
<orderQuote>
    <order_id>AZS000001</order_id>
    <user_request>
        <app_user>
            <username>varunxxxxxxxxxxxx</username>
            <user_first_name>Varun</user_first_name>
            <user_last_name>Thakur</user_last_name>
            <user_email>[email protected] /cdn-cgi/l/email-protection</user_email>          
        </app_user>

    </user_request>

    <quote_id>8975545</quote_id>
    <rate_id>ABC002</rate_id>
  <contract_id>SR_A83Z</contract_id>
    <amendment_id>20134362401</amendment_id>
  <price>60</price>
  <rate_effective_date>01-JAJ-2019</rate_effective_date>
    <rate_expiration_date>30-DEC-2019</rate_expiration_date>
    <origin_trade></origin_trade>
    <destination_trade></destination_trade>
    <origin_city>Haiphong</origin_city>
    <origin_country>VIETNAM</origin_country>
    <destination_city>Atlanta</destination_city>
    <destination_country>USA</destination_country>
    <ordermentType>XYZ</ordermentType>
    <ordermentSize>XYZ</ordermentSize>
    <ordermentSizeType>DC</ordermentSizeType>
    <currency>USD</currency>
    <order_dt>17-Sep-2019</order_dt>
    <customer>CompanyName RM Team</customer>
    <quote_creation_dt>17-Sep-2019</quote_creation_dt>

</orderQuote>

预期输出文件

 <?xml version="1.0"?>
<orderQuote>
  <order_id>AZS000001</order_id>
  <user_request>
    <app_user>
      <username>varunxxxxxxxxxxxx</username>
      <user_first_name>Varun</user_first_name>
      <user_last_name>Thakur</user_last_name>
      <user_email>[email protected] /cdn-cgi/l/email-protection</user_email>
    </app_user>

  </user_request>

  <quotationCollection>
    <quotation>
      <quote_id>8975545</quote_id>
      <rate_id>ABC002</rate_id>
      <contract_id>SR_A83Z</contract_id>
      <amendment_id>20134362401</amendment_id>
      <price>60</price>
      <rate_effective_date>01-JAJ-2019</rate_effective_date>
      <rate_expiration_date>30-DEC-2019</rate_expiration_date>
      <origin_trade></origin_trade>
      <destination_trade></destination_trade>
      <origin_city>Haiphong</origin_city>
      <origin_country>VIETNAM</origin_country>
      <destination_city>Atlanta</destination_city>
      <destination_country>USA</destination_country>
      <ordermentType>XYZ</ordermentType>
      <ordermentSize>XYZ</ordermentSize>
      <ordermentSizeType>DC</ordermentSizeType>
      <currency>USD</currency>
      <order_dt>17-Sep-2019</order_dt>
      <customer>CompanyName RM Team</customer>
      <quote_creation_dt>17-Sep-2019</quote_creation_dt>
    </quotation>
    <quotation>
      <quote_id>345678</quote_id>
      <rate_id>ABC001</rate_id>
      <contract_id>SR_ABC_XYZ</contract_id>
      <amendment_id>2019062401</amendment_id>
      <price> 10</price>
      <rate_effective_date>01-Jul-2019</rate_effective_date>
      <rate_expiration_date>30-Sep-2019</rate_expiration_date>
      <origin_trade></origin_trade>
      <destination_trade></destination_trade>
      <origin_city>Haiphong</origin_city>
      <origin_country>VIETNAM</origin_country>
      <destination_city>Atlanta</destination_city>
      <destination_country>USA</destination_country>
      <ordermentType>XYZ</ordermentType>
      <ordermentSize>XYZ</ordermentSize>
      <ordermentSizeType>DC</ordermentSizeType>
      <currency>USD</currency>
      <order_dt>17-Sep-2019</order_dt>
      <customer>CompanyName RM Team</customer>
      <quote_creation_dt>17-Sep-2019</quote_creation_dt>
    </quotation>
  </quotationCollection>
</orderQuote>

由于您想要合并多个 xml(json) 文件的部分内容,并且您的示例很复杂,所以我简化了它们。

您的要求相当于合并xml文件

<orderQuote>
    <order_id>AZS000001</order_id>
    <quote_id>345678</quote_id>
    <rate_id>ABC001</rate_id>
</orderQuote>

and

<orderQuote>
    <order_id>AZS000001</order_id>
    <quote_id>8975545</quote_id>
    <rate_id>ABC002</rate_id>
</orderQuote>

to

<orderQuote>
  <order_id>AZS000001</order_id>

  <quotationCollection>
    <quotation>
      <quote_id>8975545</quote_id>
      <rate_id>ABC002</rate_id>
    </quotation>
    <quotation>
      <quote_id>345678</quote_id>
      <rate_id>ABC001</rate_id>
    </quotation>
  </quotationCollection>
</orderQuote>

For this requirement, I initialize four variables at first(the variable "isFirstTime" is used to judge if it is the first loop in for each). enter image description here

Then I connect to ftp and parse the xml file get from ftp to json format. enter image description here

Next, I set the variable value with "order_id"(in this step, you may need to set some other variables such as "username", "user_first_name".....) enter image description here

Next step, I create a "if" condition to do different work. enter image description here

At bottom of the "For each" loop, we need to set the variable "isFirstTime" to false. enter image description here

After complete the "For each" loop, we have last two steps. enter image description here The expression of "fx concat(...)" is

concat(concat(concat(concat('{"orderQuote":{"order_id":"', variables('order_id')), '","quotationCollection":['), variables('jsonstring')), ']}}')

之后我们就可以得到json格式的结果文件。

{
  "orderQuote": {
    "order_id": "AZS000001",
    "quotationCollection": [
      {
        "quotation": {
          "quote_id": "345678",
          "rate_id": "ABC001"
        }
      },
      {
        "quotation": {
          "quote_id": "8975545",
          "rate_id": "ABC002"
        }
      }
    ]
  }
}

By the way, we'd better to do some settings before we use "For each" loop, click the "…" icon beside the "For each" action --> click "Settings" and then enable "Concurrency Control" and change the "Degree of Parallelism" to 1. enter image description here enter image description here

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在逻辑应用程序中将多个具有相同结构的 XML 文件合并为单个 xml 的相关文章

  • 跨多个 Azure Function 实例共享对象

    我们有一个要求 需要存储一个可由函数的多个实例访问和使用的对象 请告知实现此目的的最佳方法是什么 大多数时候 所有函数执行都在同一个进程中运行 因此您could使用静态类成员在函数实例之间共享状态 然而 这并不可靠 该进程可能随时停止运行
  • Azure Functions 计时器触发器线程安全

    我想知道是否有人知道如果您在 Azure 函数上设置了 Cron 设置 如果其任务执行时间超过 5 分钟 则每 5 分钟运行一次 会发生什么情况 它备份吗 或者我应该实现一个锁定功能 以防止某些东西 例如在循环中 处理先前调用已经处理的数据
  • 将 SQL 存储过程 ResultSet 表 JSON 转换为 XML

    这看起来很明显 但不知何故它对我不起作用 我正在尝试在 Microsoft Azure 上的逻辑应用程序中构建解决方案 但我无法将 JSON 对象转换为 XML 我的要求是执行存储过程并以 XML 格式保存响应 默认情况下 SQL 执行存储
  • Azure函数版本2.0-应用程序blobTrigger不工作

    我有一个工作功能应用程序 它有一个 blob 输入和一个事件中心输出 在测试版中工作 随着最新的更改 我的功能不再起作用 我尝试根据发行说明更新 host json 文件 但它没有引用 blob 触发器 version 2 0 extens
  • 耐用功能是否适合大量活动?

    我有一个场景 需要计算 500k 活动 都是小算盘 由于限制 我只能同时计算 30 个 想象一下下面的简单示例 FunctionName Crawl public static async Task
  • 如何通过 Kudu Api 动态运行手动部署在门户上的 azure 函数?

    我在门户上部署了一个时间触发器天蓝色功能 每天上午 10 00 运行 然而 现在要求函数也应该在其他时间动态调用和运行 我知道如何使用上述答案中的步骤通过 Kudu Api 动态设置 function json 文件中的触发器here ht
  • Blazor WASM(独立)B2C 身份验证与 Azure Function App 身份验证

    我正在开发 Blazor WASM 独立 不是 ASP NET 核心托管 应用程序 该应用程序已与我的 B2C 租赁集成以进行用户身份验证 我能够成功地针对 B2C 进行身份验证 没有出现任何问题 在另一个 Azure 目录中 我有一个启用
  • 如何在 Azure Functions 3.x PowerShell 7 中调用 Azure PowerShell 模块命令?

    我需要运行 Azure PowerShell 模块命令 https learn microsoft com en us powershell azure install az ps view azps 5 2 0 https learn m
  • 在 Postman 中请求受 Azure AD B2C 保护的 Azure 函数应用程序的访问令牌

    我有一个由 Azure Active Directory B2C 租户保护的 AspNetCore 2 0 MVC Web API 我已经能够通过以下 SO 发布使用 Postman 来测试 API 端点 在 Postman 中请求 Azu
  • 设置缩略图内容类型

    我需要设置Content Type对于缩略图 我已经尝试如下所示 但它不起作用 仍然 它存储为流 天青功能 索引 json var Jimp require jimp module exports context myBlob gt Rea
  • 如何为 Azure Function 启用“始终开启”功能?

    我有一个具有 3 个功能的功能应用程序 其中一个功能每 2 分钟定时器触发一次 我观察到 过了一会儿 该功能停止被触发 但当我进入门户时又重新启动 据我了解 原因是默认情况下 始终开启 处于关闭状态 但是 当我进入应用程序设置 常规设置时
  • Azure 函数和文档数据库

    我很好奇 Azure Functions 上的缩放与输出到文档数据库的关系如何 基本上 当文档数据库因为超出分配的吞吐量而返回 429 时会发生什么 我之所以这么问 是因为当我将最低级别的 Azure Functions 与最低级别的文档数
  • 无法创建集合信息 - 尝试在本地测试 Cosmos DB 触发器时出错

    我正在测试开发一个 Azure 函数来读取 Cosmos DB 数据库的更改源 我已经从 Azure 门户创建了这样的函数 但我想使用 VS 或 VS Code 来执行此操作 我使用 Azure Function Core Tools v2
  • 如何使用我的 DNS 服务器获取 Azure 容器实例?

    In ACI https learn microsoft com en us azure container instances container instances overview我们使用具有虚拟网络支持的 Linux 容器 我们运行
  • HTTP按需触发azure函数多次调用自身

    我添加了http触发的azure函数并将其部署在函数应用程序中 函数应用程序仅包含一个此 http 按需触发器 azure 函数 功能应用程序有应用程序服务计划 而不是消费计划 另外 函数应用程序版本为 1 所以超时是无限的 在天蓝色的函数
  • 用 Node.js 编写的 Azure Functions 可以访问连接字符串吗?

    Azure Function App 的应用程序设置包含可在门户中设置的数据库连接字符串的值 在 C 中 可以使用以下方式访问它们 ConfigurationManager ConnectionStrings ConnectionStrin
  • Azure 逻辑应用服务总线消息内容

    我有由服务总线触发的逻辑应用程序 消息内容不可用 因为它只是随机字符 我怀疑也许需要对其进行解析 但尚不清楚如何执行此操作 我有以下内容 声誉不足 无法添加图像 但来自 Azure 的屏幕截图 https i stack imgur com
  • 如何在 Azure Function 中使用 TelemetryConfiguration 的依赖项注入

    我尝试在 Azure Functions 中使用依赖项注入进行 TelemetryConfiguration 在我的函数中 当我在函数构造函数中注入 TelemetryConfiguration 时 我将解决它 我想我不太明白如何在 Sta
  • 逻辑应用 blob 触发器未在子文件夹上触发

    我指的是这个反馈 在子文件夹中添加文件时触发 Azure 存储 Blob 触发器 https feedback azure com forums 287593 logic apps suggestions 20164843 azure st
  • Azure Functions 如何横向扩展?

    The Azure Functions 的扩展文档 https azure microsoft com en us documentation articles functions scale 详细介绍了 Azure Functions 如

随机推荐