I want to load an xml file and convert it into JSON in angularjs on the client side.
1 Answer
You have two options.
- Return the data from the API in format you require to prevent conversions (recommended).
- Convert the XML to JSON using javascript.
For approach #2 I'll recommend you this solution http://goessner.net/download/prj/jsonxml/
And please be sure to read the article 'Converting Between XML and JSON' (by Stefan Goessner) to overview details of the problems with conversions.
xml
on your server than convert it tojson
than response it toangularjs
.