简体   繁体   English

Azure将XML转换为JSON

[英]Azure Transform XML to JSON

I'm trying to transform the following XML into JSON using Azure liquid mapping to find the session ID. 我正在尝试使用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>

I'm trying to use this liquid file to convert the XML to find the sessionID in JSON. 我正在尝试使用此液体文件转换XML以在JSON中查找sessionID。

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

This just returns no value in the output: 这只是在输出中没有返回值:

{
  "Session": ""
}

Can someone help me with this? 有人可以帮我弄这个吗?

As an alternative to using a liquid map, you can wrap the xml data in a json() workflow function. 作为使用液体贴图的替代方法,您可以将xml数据包装在json()工作流程函数中。 The statement would look like this: 声明如下:

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

This xml function above is used because the outputs from a Compose action named Mock_example_data is in string form. 使用上面的xml函数是因为名为Mock_example_dataCompose操作的outputs是字符串形式。

Got the answer, 得到了答案,

{

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

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM