I want to load an xml file and convert it into JSON in angularjs on the client side.
Asked
Active
Viewed 502 times
0
-
Try http://stackoverflow.com/questions/1773550/convert-xml-to-json-and-back-using-javascript – Ivan Shulev Oct 03 '15 at 05:22
-
I think better option is to first grab `xml` on your server than convert it to `json` than response it to `angularjs`. – Indrasinh Bihola Oct 03 '15 at 06:59
1 Answers
0
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.

Yuriy A.
- 750
- 3
- 19