【问题标题】:Azure Transform XML to JSONAzure 将 XML 转换为 JSON
【发布时间】:2019-03-06 16:10:43
【问题描述】:

我正在尝试使用 Azure 液体映射将以下 XML 转换为 JSON 以查找会话 ID。

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<LogInResponse xmlns="http://tempuri.org/RLXSOAP19/RLXSOAP19">
<LogInResult>
<ExceptionCode>0</ExceptionCode>
<ExceptionDescription>No error</ExceptionDescription>
</LogInResult>
<SessionID>A VALUE</SessionID>
</LogInResponse>
</soap:Body>
</soap:Envelope>

我正在尝试使用这个液体文件来转换 XML 以在 JSON 中找到 sessionID。

{
"Session": "{{content.soap:Envelope.soap:Body.LogInResponse.SessionID}}"
}

这只是在输出中不返回任何值:

{
  "Session": ""
}

有人可以帮我解决这个问题吗?

【问题讨论】:

    标签: json xml azure azure-logic-apps dotliquid


    【解决方案1】:

    作为使用流图的替代方法,您可以将 xml 数据包装在 json() 工作流函数中。语句如下所示:

    @json(xml(outputs('Mock_example_data')))['soap:Envelope']['soap:Body']['LogInResponse']['SessionID']
    

    之所以使用上述xml 函数,是因为来自名为Mock_example_dataCompose 操作的outputs 是字符串形式。

    【讨论】:

      【解决方案2】:

      找到答案了,

      {
      
      "Session": "{{content.Envelope.Body.LogInResponse.SessionID}}"
      
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-05-09
        • 1970-01-01
        • 2015-05-30
        • 2017-08-07
        • 2018-08-15
        • 2014-07-30
        • 2017-07-04
        相关资源
        最近更新 更多