title: Converting xml to json using axios
body: <pre><code>  componentDidMount() {
      axios.get('http://thecatapi.com/api/images/get?format=xml&amp;results_per_page=20')
      .then((response) =&gt; {
        console.log(response.data);
      });
    }
  </code></pre>
  
  <p>my response.data is just an xml file, how can I parse this to json I have tried > <code>(JSON.parse()</code>. I then want to set the state and put each cat as an object in my array.</p>
  
  <p>but when I do <code>this.setState(cats: this.state.cats.concat(response)</code> I just an array with one big object in it</p>
  
  <p>I'm confused as to do what to do when I get my response back and how to use it</p>
  
  <p>thanks</p>
  
  <p>response.data im getting at the moment:</p>
  
  <pre><code>&lt;response&gt;
    &lt;data&gt;
      &lt;images&gt;
        &lt;image&gt;
          &lt;url&gt;http://24.media.tumblr.com/tumblr_m4ceddr9GM1qcxyrro1_1280.jpg&lt;/url&gt;
          &lt;id&gt;de5&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=de5&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://24.media.tumblr.com/tumblr_lwgyvtZTRT1qhpojco1_500.jpg&lt;/url&gt;
          &lt;id&gt;50f&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=50f&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_lzobekds0b1qgjltdo1_1280.jpg&lt;/url&gt;
          &lt;id&gt;c8v&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=c8v&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/YuqJHp0AQh2ggs7tGJThUhhyo1_1280.jpg&lt;/url&gt;
          &lt;id&gt;ah7&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=ah7&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_m1mg9xfGfN1qay66po1_500.jpg&lt;/url&gt;
          &lt;id&gt;354&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=354&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://24.media.tumblr.com/tumblr_ma7jlxaQrH1r6jd7fo1_500.jpg&lt;/url&gt;
          &lt;id&gt;MjA2NDUzMg&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=MjA2NDUzMg&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://24.media.tumblr.com/tumblr_lnjo1hH8DW1qljvf7o1_400.jpg&lt;/url&gt;
          &lt;id&gt;cl2&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=cl2&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_m2pi5dzrUr1rohhvpo1_1280.jpg&lt;/url&gt;
          &lt;id&gt;47u&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=47u&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_mcey3xJG7K1qzex9io1_500.jpg&lt;/url&gt;
          &lt;id&gt;MTUyNDU4Ng&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=MTUyNDU4Ng&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://24.media.tumblr.com/tumblr_lmtz3wcDVg1qz5b0yo1_1280.jpg&lt;/url&gt;
          &lt;id&gt;MTg3MzgwMA&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=MTg3MzgwMA&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_m3v14bcN4o1qz4ueho1_1280.jpg&lt;/url&gt;
          &lt;id&gt;3u1&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=3u1&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_lwlgt2LesO1qe49wpo1_500.jpg&lt;/url&gt;
          &lt;id&gt;6pk&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=6pk&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_m4ilnjcGek1r6jd7fo1_500.jpg&lt;/url&gt;
          &lt;id&gt;egj&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=egj&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_ltsphdITe71qehxqmo1_400.gif&lt;/url&gt;
          &lt;id&gt;5td&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=5td&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://24.media.tumblr.com/tumblr_m1jodvuOuz1qzyqubo1_1280.jpg&lt;/url&gt;
          &lt;id&gt;a03&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=a03&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://29.media.tumblr.com/Jjkybd3nSjcof95aUBOP7Rl2o1_500.jpg&lt;/url&gt;
          &lt;id&gt;2cd&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=2cd&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_lz81x4TNCE1rpsftmo1_500.gif&lt;/url&gt;
          &lt;id&gt;4ha&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=4ha&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://24.media.tumblr.com/tumblr_lncvcuNpEB1qbe5pxo1_500.jpg&lt;/url&gt;
          &lt;id&gt;9hs&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=9hs&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://24.media.tumblr.com/tumblr_m52cqek4wK1rurnfyo1_400.gif&lt;/url&gt;
          &lt;id&gt;MTU2NzAyOA&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=MTU2NzAyOA&lt;/source_url&gt;
        &lt;/image&gt;
        &lt;image&gt;
          &lt;url&gt;http://25.media.tumblr.com/tumblr_m2tglif3SI1r73wdao1_500.jpg&lt;/url&gt;
          &lt;id&gt;7qk&lt;/id&gt;
          &lt;source_url&gt;http://thecatapi.com/?id=7qk&lt;/source_url&gt;
        &lt;/image&gt;
      &lt;/images&gt;
    &lt;/data&gt;
  &lt;/response&gt;
  </code></pre>