My colleague has given each element in a payload a namespace ns0
for best practice, and my parser stopped working. Reading more on the topic, it seems that declaring each element the namespace is not necessary; it can be set at the root?
When you use multiple namespaces in an XML document, you can define one namespace as the default namespace to create a cleaner looking document. The default namespace is declared in the root element and applies to all unqualified elements in the document. Default namespaces apply to elements only, not to attributes.
Source: https://learn.microsoft.com/en-us/dotnet/standard/data/xml/managing-namespaces-in-an-xml-document
What's the correct approach?
<ns0:Root
xmlns:ns0="urn:asw:erT"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:urn="urn:asw:erT">
<ns0:Ticket
xmlns:urn="urn:asw:erT" Code="TEST" Key="1">
<ns0:client>
<ns0:CardNumber>12345</ns0:CardNumber>
<ns0:OpenPointsBalance>14352</ns0:OpenPointsBalance>
<ns0:PointsEarnedValue>46</ns0:PointsEarnedValue>
<ns0:PointsClosingBalance>14398</ns0:PointsClosingBalance>
</ns0:client>
</ns0:Ticket>
</ns0:Root>