Angular: Convert XML to JSON

前端 未结 3 1388
清酒与你
清酒与你 2020-12-10 07:26

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         


        
3条回答
  •  执笔经年
    2020-12-10 08:03

    function parseXml(xmlStr) {
        var result;
        var parser = require('xml2js');
        parser.Parser().parseString(xmlStr, (e, r) => {result = r});
        return result;
    }
    

提交回复
热议问题