Extract SOAP/XML namespaces as a list of key/value pairs using JavaScript
<p>Here's a SOAP response that I want to use javascript to extract a list of key value pairs where the key is the local namespace element prefix, such as:</p>

<p><code>SOAP-ENV</code><br><code>ns98</code><br><code>ns70</code><br></p>

<p>and the value is the namespace definition, such as:</p>

<p><code>http://schemas.xmlsoap.org/soap/envelope/</code><br><code>urn:vertexinc:enterprise:platform:security:messages:1:0</code><br><code>urn:vertexinc:enterprise:platform:security:1:0</code></p>

<pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
&lt;SOAP-ENV:Header/&gt;
&lt;SOAP-ENV:Body&gt;
     &lt;ns98:ExecuteLoginResponse
        xmlns:ns70="urn:vertexinc:enterprise:platform:security:1:0"
        xmlns:ns98="urn:vertexinc:enterprise:platform:security:messages:1:0"&gt;
        &lt;ns70:UserLoginConfirmation&gt;
            &lt;ns70:UserName&gt;platformadmin&lt;/ns70:UserName&gt;
            &lt;ns70:LoginResult&gt;SUCCESS&lt;/ns70:LoginResult&gt;
            &lt;ns70:LastLoginDate&gt;2016-01-26T17:28:02.109&lt;/ns70:LastLoginDate&gt;
            &lt;ns70:DefaultAsOfDate&gt;2016-01-26&lt;/ns70:DefaultAsOfDate&gt;
            &lt;ns70:ForcePasswordChange&gt;false&lt;/ns70:ForcePasswordChange&gt;
        &lt;/ns70:UserLoginConfirmation&gt;
    &lt;/ns98:ExecuteLoginResponse&gt;
&lt;/SOAP-ENV:Body&gt;
&lt;/SOAP-ENV:Envelope&gt;
</code></pre>

<p>My research thus far indicates a general lack of need to do something like this, most people either strip the name space from the elements of the part of the document that they care about, or they simply ignore the namespace. At the moment I am stripping the namespace values, but for debugging purposes would like to inspect the namespaces that were used in the response.</p>

<p>An interesting aspect of the service being used is that the nsXX values can vary for each invocation (e.g. ns70 could be ns78 next time the method is invoked). This means that I cannot key on a fixed namespace value. Additionally, the namespace values for these messages in the WSDL don't seem to have any correspondence to the namespace values in the response.</p>

<p>XPath seems like it might be able to help here, or I could just write my own, but I'd prefer to leverage an existing approach. At this point I'm just trying to understand the problem space and would appreciate some guidance with regard to where to start my education process. (please point me in the right direction)</p>