Malformed XML response with manual newline characters


I am using a GET request to fetch what I expect to be an XML document from an endpoint. The response has the following structure:

'  <itunes:explicit>clean</itunes:explicit>\n' +
'  <itunes:episode>11</itunes:episode>\n' +
'  <itunes:episodeType>full</itunes:episodeType>\n' +

(This is from a console log in a Node.js function).

I haven’t encountered a response like this before and am having trouble doing anything useful with it. I’ve tried:

  • Changing the response type and encoding of my GET function
  • Parsing the response with an XML parser – this throws an error
  • Removing the newline and + characters manually with regex (I’d like to avoid this, but it doesn’t seem to work anyway)

It’s worth saying that the response looks as you’d expect in a browser window:

enter image description here

Am I missing something fundamental about how this data is encoded / structured and what is the best way to turn it into something I can work with?


Rookie error. In case anyone else stumbles across this; I expected the response from my Axios GET request to be the xml. The response was actually in a data property in the response:

const response = await axios.get(url);
const myXML =;

Answered By – Matt Saunders

Answer Checked By – Cary Denson (AngularFixing Admin)

Leave a Reply

Your email address will not be published.