Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert JSON object to XML using javascript

I want to convert a JSON object to a XML String and I can't figure a proper way to do it. I've found a neat little jQuery plugin called json2xml at https://gist.github.com/c4milo/3738875 but it doesn't escape the data.

How can I escape the data properly so that the browser's XML parser will work?

like image 272
Andrew M Avatar asked Jul 26 '26 21:07

Andrew M


2 Answers

You can try this small library http://code.google.com/p/x2js/

like image 160
abdolence Avatar answered Jul 29 '26 15:07

abdolence


There is no unique way of doing this. You should be using XML with a schema only, and JSON doesn't have such a schema. Any such transformation when done naively is likely to break.

Why don't you just use XML or JSON consequently?

like image 22
Has QUIT--Anony-Mousse Avatar answered Jul 29 '26 14:07

Has QUIT--Anony-Mousse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!