How to set XML response into model.
This is the model class
export class Region {
public regionCode : number;
public regionName : string;
}
This is how I had done with JSON data
Component
typeMasterList: Region [];
this.masterDataService.typeMaster().subscribe(response => {
this.typeMasterList = response['requests'];
});
This is what I tried with XML.
Sample request
<requests>
<region>
<regionCode>50002</regionCode>
<regionName>STUV</regionName>
</region>
<region>
<regionCode>50003</regionCode>
<regionName>AINL</regionName>
</region>
</requests>
I had added this in http get call { responseType: 'text' }
this.masterDataService.typeMaster().subscribe(response => {
console.log("key :"+data); // displays full text.
this.typeMasterList = response['requests']; // but this not working, as its xml response.
});
How can I assign the response to the array ?