[英]Unable to parse xml with null content in azure logic apps
我正在获取具有以下结构的XML
<?xml version="1.0" encoding="UTF-8"?>
<Data>
<datym>
<bla bla>
</datym>
<datym>
<bla bla>
</datym>
</Data>
我可以成功解析为json并完成所有工作。 有时我得到以下格式的空xml。
<?xml version="1.0" encoding="UTF-8"?>
<Data></data>
但是,这无法使用逻辑应用程序解析为xml或json。那么,如果这是可解析的XML或空的XML,我该如何进行验证? 我想到了在启动字符串后使用contains()函数,但这对性能造成了巨大影响。
感谢您的想法。
我以为您的空xml示例可以解析。 我试图将xml文件解析为json文件。 这是我的xml内容。
<Invoices
xmlns="http://gateway.com/schemas/Invoices"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://gateway..com/schemas/Invoices Invoices.xsd">
<DocumentInfo></DocumentInfo>
<Header></Header>
<Documents></Documents>
</Invoices>
解析后,这是json内容:
{
"Invoices": {
"@xmlns": "http://gateway.com/schemas/Invoices",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"@xsi:schemaLocation":
"http://gateway..com/schemas/InvoicesInvoices.xsd",
"DocumentInfo": "",
"Header": "",
"Documents": ""
}
}
因此,也许您可以参考我的Logic App流程。 我使用xml文件作为显示。
希望这对您有帮助,如果您还有其他问题,请告诉我。
我实际上找到了解决此问题的方法。 所以我想我会自己回答,以便将来其他人会觉得有用。
我的方法是使用XPATH。
只需检查第一个节点。 如果返回空数组,则返回空数组,否则进行常规处理。
xpath(xml(base64ToString(variables('content'))),'//datym')
要么
xpath(xml(base64ToString(variables('content'))),'//datym[1]')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.