【发布时间】:2021-04-28 13:44:31
【问题描述】:
我正在尝试使用 Azure 数据工厂从 API 读取数据。首先,我需要调用一个提供 XML 响应的登录方法。我需要从该 XML 中获取一个元素并将其放入我的下一个 API 调用中以获取我需要的数据。
目前我正在使用复制数据工具来调用登录方法并将 XML 保存到 blob 存储。我现在如何将该 XML 的元素读入变量中?
如果有更好的方法,请指教,但我仍然想知道如何将 XML 元素读入变量。
编辑:这里是返回的 XML。我需要捕获 SessionID。
<?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>
<DoLoginResponse xmlns="http://foo.bar">
<DoLoginResult>
<OperationStatus>true</OperationStatus>
<StatusMessage />
<SecurityProfile>
<User></User>
<Session>
<SessionId>d2cf6ea6-120f-4bff-a5d1-adad9063d9d2</SessionId>
</Session>
<IsFirstLogon>true</IsFirstLogon>
<IsSystemOwner>false</IsSystemOwner>
</SecurityProfile>
</DoLoginResult>
</DoLoginResponse>
</soap:Body>
</soap:Envelope>
【问题讨论】:
-
是否要将xml文件的一部分提取到字符串变量中?
-
您能给我们展示一些示例数据以及您要提取的部分吗?
-
我认为 ADF 不支持这样处理 XML 内联。一种想法是将 XML 有效负载传递给 Azure 函数,该函数对其进行解析并将其作为 JSON 返回,这将很容易读取到变量中。