I have this method where I receive an XML response from a remote server and I need to convert the XML to JSON so that Angular 2 can work with the data:
priv
function parseXml(xmlStr) { var result; var parser = require('xml2js'); parser.Parser().parseString(xmlStr, (e, r) => {result = r}); return result; }