Retrieve XML from HTTPClient on Angular 5
If you want to get the response as text. You can try adding { responseType: 'text' }.
{
headers: new HttpHeaders()
.set('Content-Type', 'text/xml')
.append('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,PATCH,OPTIONS')
.append('Access-Control-Allow-Origin', '*')
.append('Access-Control-Allow-Headers', "Access-Control-Allow-Headers, Access-Control-Allow-Origin, Access-Control-Request-Method")
, responseType:'text'}
If { responseType: 'text' }
didn't do the trick, try { responseType: 'text' as 'text' }
.
To convert the XML response to JSON, I used the script from this website XMLParser based on Lodash.
Another solution you can use is xml2js.