How to use XML response in react-native
<p>I am developing an mobile application by <code>react-native</code>, I have to call a odata service which returns <code>XML</code> and I need to convert that to <code>json</code> object.</p>

<p>How should I do that?</p>

<pre><code>return fetch(url, {
      method: 'GET',
      headers: {
        Authorization: config.api.auth,
      },
    })
      .then(response =&gt; response.json())
      // .then(response =&gt; response.text())
      // .then(xml =&gt; _xmlToJson(xml))
      .then(json =&gt; dosomething(json))
      .catch(ex =&gt; showError(ex));
  };
</code></pre>

<p>I tried to get <code>text()</code> instead on <code>json()</code> and pass it to another method which converts <code>xml</code> to <code>json</code> but the problem is that method needs a <code>xml object</code> but <code>text()</code> returns string, and I couldn't find a way in <code>react-native</code> to convert <code>string</code> to <code>xml</code>.</p>

<p>p.s. Since React Native using <code>JavaScriptCore</code>, which is just a javascript interpreter, so no Browser Object Model, no document object, no window, etc can be used</p>