0

I'm developing an Angular2 application. This app, call a WebService that return an Xml response. My Service class that call webservice has this method:

callPost() {
    return this.http.post(this.baseUrl, '&param=value'
  , { headers: this.getHeaders() }).map(res => res);
}

where getHeaders function is

 private getHeaders() {
    let headers = new Headers();
    headers.append('Content-Type', 'application/x-www-form-urlencoded');
    return headers;
 }

I call function inside my component class in this way:

this.myService.callPost().subscribe(
  resp => this.resp = resp,
  error => alert(error),
  () => console.log(this.resp.text())
)

As i've noticed, xml response is inside this.resp.text()

Now i need to extract data from that xml (tag with attributes and value between tags), and i don't know how to do (i've stard developing in Angular2 yesterday). Can someone explane me how to procede?

1 Answer 1

1

Th easiest route is to add an external module that converts your incoming XML back to JSON. This is a good option: https://www.npmjs.com/package/xml2js.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.