I am simply trying to retrieve xml data from some domain and read them onto my application. For now, I just want to read raw data. From my research, It comes to me that it is best to convert xml into json and load them onto the application. Here is what I tried to convert and print them. Could anyone advice on what I am doing wrong?
getProduction() {
var headers = new Headers({ 'Content-Type': 'text/xml'})
headers.set('Accept', 'text/xml');
headers.set('Content-Type', 'text/xml');
//make the http request
return this.http.get(this.url, {headers: headers})
.map(res => JSON.parse(parseString(res.text(),'')))
//Print JSON data?
.subscribe(data =>{console.log(data);});
}
private handleErorr( error: Response){
console.log('something went wrong');
return Observable.throw(error.json().error || 'server error');
}