【发布时间】:2016-06-12 07:05:31
【问题描述】:
我是 Mulesoft 的新手,正在努力创建一个流程,我正在使用一个将 XML 作为输出的 Web 服务,我需要在 Mule 中将 XML 转换为 JSON。
下面是我的Mule流程,
下面是 Postman Pretty 值,
<?xml version="1.0" encoding="UTF-8"?>
<GetProjectResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="namespaceName">
<GetProjectResult><root>
<header>
<status>
<message>Success</message>
</status>
</header>
<data>
<Project>
<ProjectId>12345</ProjectId>
<ProjectShortName>ABCDEF</ProjectShortName>
<BusinessGroupName>ABCDEF GROUP</BusinessGroupName>
<InstitutionShortName>Country</InstitutionShortName>
<CountryName>Sample</CountryName>
<Code>Sample</Code>
</Project>
</data>
</root></GetProjectResult>
</GetProjectResponse>
但我的 JSON 看起来像这样,
{
"GetProjectResponse": {
"@xmlns:xsd": "http://www.w3.org/2001/XMLSchema",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"@xmlns:xmlns": "namespaceName",
"GetProjectResult": "<root>\n <header>\n <status>\n <message>Success</message>\n </status>\n </header>\n <data>\n <Project>\n <ProjectId>12345</ProjectId>\n <ProjectShortName>ABCDEF</ProjectShortName>\n <BusinessGroupName>ABCDEF GROUP</BusinessGroupName>\n <InstitutionShortName>Country</InstitutionShortName>\n <CountryName>Sample</CountryName>\n <Code>Sample</Code>\n </Project>\n </data>\n</root>"
}
}
我的实际 XML 是“GetProjectResult”节点内的值,有人可以告诉我如何实现这一点。
【问题讨论】:
标签: mule