【发布时间】:2017-08-01 02:05:56
【问题描述】:
我有以下肥皂响应作为示例:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:mycompany:Service:2" xmlns:urn1="urn:mycompany:Customer:2">
<soapenv:Header />
<soapenv:Body>
<urn:GetResponse>
<urn:StatusCode>002</urn:StatusCode>
<urn:StatusMessage>Pass</urn:StatusMessage>
<urn:CustomerAffiliations>
<urn:CustomerAffiliation>
<urn:CustomerID>II39642</urn:CustomerID>
<urn:CustomerContactDetails>
<ns3:Channel xmlns:ns3="urn:mycompany:Customer:2">Business Phone</ns3:Channel>
<ns3:Value xmlns:ns3="urn:mycompany:Customer:2">5553647</ns3:Value>
</urn:CustomerContactDetails>
</urn:CustomerAffiliation>
</urn:CustomerAffiliations>
</urn:GetResponse>
</soapenv:Body>
</soapenv:Envelope>
urn:mycompany:Customer:2 已作为 urn1 包含在 soapenv:Envelope 中,但在 ns3:Channel 和 ns3:Value 中重复。
要求是清理 xml 内容,以便在子元素中使用 soapenv:Envelope 中声明的正确命名空间。
Java 中是否有办法清理/规范化此 xml 内容并使用正确的命名空间使用和重复删除?
【问题讨论】: