首页 > 解决方案 > 无法在 Azure 逻辑应用程序中解析具有空内容的 xml

问题描述

我得到一个具有以下结构的 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() 函数,但这对性能造成了巨大的影响。

谢谢你的想法。

标签: jsonxmlazureazure-logic-apps

解决方案


我认为您的空 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": ""
  }
}

所以也许你可以参考我的逻辑应用流程。我使用 xml 文件作为显示。

在此处输入图像描述

希望这对您有所帮助,如果您还有其他问题,请告诉我。


推荐阅读