Angular2: Convert XML to JSON

前端 未结 3 1738
予麋鹿
予麋鹿 2020-12-16 04:13

I wanted to convert the XML I received from Web API response to JSON in Angular 2. The application is developed in Nativescript. Not able to find a solution for this.

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-16 04:44

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

提交回复
热议问题