how to get xml namespace in javascript
<p>my <code>xml</code> is </p>

<pre><code>&lt;message to="to_test" from="from_test"&gt;
    &lt;test xmlns="google:mobile:data"&gt;
        {"message":"test_message"}
    &lt;/test&gt;
&lt;/message&gt;
</code></pre>

<p>i get the value <code>{"message":"test_message"}</code> by using the function <code>getChildText("pcm")</code>. But i tried to retrieve the namespace <code>xmlns</code> value.</p>

<p>I tried the following <a href="https://stackoverflow.com/questions/16652624/how-to-get-xml-namespace">How to get XML namespace?</a> , <a href="https://stackoverflow.com/questions/25064078/how-to-get-specific-xml-namespace-in-xquery-in-sql-server">How to get specific XML namespace in XQuery in SQL Server</a> with no luck, it shows me <code>is not function error</code> what i'm doing wrong?</p>

<p>I forgot to mention, I'm currently staring work with <strong>node.js</strong>.</p>

<p><strong>update</strong></p>

<p>the above xml output is  <code>xmpp stanza</code>.</p>

<p>Here i'm getting the <code>attrs</code> using the following.</p>

<p><code>stanza.attrs.to</code> gives me <code>to_test</code>.</p>

<p><code>stanza.attrs.from</code> gives me <code>from_test</code>.</p>

<p><code>stanza.getChildText("test")</code> gives me <code>{"message":"test_message"}</code></p>

<p>I tried to get the <code>xmlns</code> using  </p>

<pre><code>    var parser = new DOMParser();
    var documents = parser.parseFromString(stanza, 'text/xml');
    var response = documents.responseXML.getElementsByTagName("test");
    var sunrise = response[0].getElementsByTagNameNS("[Namespace URI]", "test")[0].getAttribute("xmlns");
    console.log(sunrise);
</code></pre>

<p>here i got</p>

<pre><code>[xmldom error]  element parse error: TypeError: source.indexOf is not a function @#[line:0,col:undefined]
</code></pre>