I have the following soap response as a sample:
<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
has been included as urn1
in soapenv:Envelope
but it is duplicated in ns3:Channel
and ns3:Value
.
The requirement is to clean the xml content so the correct namespaces declared in soapenv:Envelope
is used in the child elements.
Is there a way in Java to clean/normalize this xml content and use proper namespace usage and duplication removal?