Wednesday, May 28, 2014

XML String to JSON conversion in javascript


I found this nice simple jquery plugin that helps convert xml string into JSON object directly converts xml string into json object in javascript. Following is a simple html file that I used to test my way through with this plugin. So my motive is to get a message box in the browser saying “Hello World” through the following file. Hope I don’t have to speak much about this file as its very plain and simple





                                <script type='text/javascript' src='jquery.js'></script>

                                <script type='text/javascript' src='jquery.xml2json.js'></script>                               

                                <script type='text/javascript'>

                                                function xmlToJsonTest()             {

                                                                var xml = '<xml><message>Hello world</message></xml>';

                                                                var json = $.xml2json(xml);






                <body onload='xmlToJsonTest()'>XML To JSON Test</body>





You can find this xml to json convertor jquery plugin in .


You can go through the site for examples and if you would like to skip the hard part here is the direct download link for the same site for the plugin


Hope this helps



No comments:

Post a Comment