I have a requirement that my API will return XML response. I want to display it on HTML page using Angular2. How do I achieve that? I am using xml2js node module to parse xml. this is my code
import * as xml2js from 'xml2js';
/* This is sample demo I am working on.In future data will come
from API
*/
showData() {
const xml = '<root>Hello xml2js!</root>';
xml2js.parseString(xml, function (err, result) {
console.dir(result);
});
}
From the above code I want to display "Hello xml2js" in HTML page. How do I achieve that in angular 2?