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



1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training from India . Nowadays Java has tons of job opportunities on various vertical industry.