简体   繁体   English

如何使用angular.js将xml解析为JSON?

[英]How to parse xml into JSON using angular.js?

I am trying to parse XML in angular.js, but it is very time consuming. 我正在尝试在angular.js中解析XML,但这非常耗时。 Is there any smarter and faster way available to parse XML in angular.js. 是否有任何更智能,更快速的方法可用来解析angular.js中的XML。

you can parse the xml using DomParser in core javascript,but it time consuming so i suggest you to use jQuery XML to JSON Plugin download plugin from url https://www.fyneworks.com/jquery/xml-to-json/ 您可以在核心javascript中使用DomParser解析xml,但是这很耗时,因此我建议您使用url从https://www.fyneworks.com/jquery/xml-to-json/将jQuery XML转换为JSON插件下载插件

and use it following way 并按照以下方式使用

var ajaxRequest = $http.get(UrlForService);
ajaxRequest .success(function(data){
  $scope.list = $.xml2json(data); // parsing xml response into Json
});

and use the list variable in your template whatever way you want- 并根据需要在模板中使用list变量-

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM