Convert XML to JSON in ionic v1?


#1

Does anyone know any plugins that will help me convert an $http request from XML to JSON with Ionic version 1?

Thanks.


#2

Look at this library: https://www.npmjs.com/package/xml-js


#3

It doesn’t look like this package would work with the Angular 1 version.


#4

It is just Javascript. I use it in an Angular 1/Electron project with no issue.


#5

Oh, maybe I misread it. How do you inject it as a dependency in angular 1? The docs are using a require statement to pull in the library.


#6

To be more specific, how would I use it in this situation:

$http.jsonp("http://www.myfile.xml"
                ).success(function (response) {
                    // convert to json
                }).error(function(error) {
                    // show error
                });

#7

Hello @Joshblf where you able to fix this? I’m currently facing the same issue