I think this is the best one: Converting between XML and JSON

Be sure to read the accompanying article on the xml.com O'Reilly site, which goes into details of the problems with these conversions, which I think you will find enlightening. The fact that O'Reilly is hosting the article should indicate that Stefan's solution has merit.

Answer from Josh Stodola on Stack Overflow
🌐
GitHub
github.com › estheban › node-json2xml
GitHub - estheban/node-json2xml: A small JSON to XML parser
// none: json2xml({ a: 1 }); //<a>1</a> // empty node: json2xml({ a: '' }); //<a/> // add header: json2xml({ a: 1 }, { header: true }); //<?xml version="1.0" encoding="UTF-8"?><a>1</a> // add node attributes: json2xml({ a: 1, attr: { b: 2, c: ...
Starred by 66 users
Forked by 30 users
Languages   JavaScript 100.0% | JavaScript 100.0%
🌐
Npmdoc
npmdoc.github.io › node-npmdoc-xml-js › build › apidoc.html
function xml-js.js2xml (js, options)
... To convert XML text to JavaScript object, use `xml2js()`. To convert XML text to JSON text, use `xml2json()`. ```js var convert = require('xml-js'); var xml = require('fs').readFileSync('test.xml', 'utf8'); var options = {ignoreText: true, alwaysChildren: true}; var result = convert.xml2js(xml, ...
🌐
npm
npmjs.com › package › json2xml
json2xml - npm
November 14, 2016 - Simple JavaScript Object to XML string converter. Install via npm, which will download json2xml and all of its dependencies.
      » npm install json2xml
    
Published   Nov 14, 2016
Version   0.1.3
Author   Etienne Lachance
🌐
GitHub
github.com › abdolence › x2js
GitHub - abdolence/x2js: x2js - XML to JSON and back for JavaScript · GitHub
var testObjC = { 'm:TestAttrRoot' : { '_tns:m' : 'http://www.example.org', '_tns:cms' : 'http://www.example.org', MyChild : 'my_child_value', 'cms:MyAnotherChild' : 'vdfd' } } var xmlDocStr = x2js.json2xml_str( testObjC );
Starred by 1K users
Forked by 479 users
Languages   JavaScript 55.6% | HTML 44.4%
🌐
Medium
medium.com › @polyismstudio › converting-json-from-and-to-xml-in-javascript-9d3d8288331f
Converting JSON from and to XML in Javascript | by Sem Postma | Medium
December 1, 2018 - Converting JSON from and to XML in Javascript Checkout the website: JSON2XML or the full example. As it turns out, finding a good xml to json javascript library is not as easy as it sounds. I did …
🌐
GitHub
github.com › mevdschee › json2xml.js
GitHub - mevdschee/json2xml.js: Two JavaScript functions that allow you to convert from JSON to XML and back
Two JavaScript functions that allow you to convert from JSON to XML and back (not the other way around). This implementation is using the Microsoft JSON-XML mapping as described here: https://msdn.microsoft.com/en-us/library/bb924435(v=vs.110).aspx · See also: https://github.com/mevdschee/json2xml.php
Starred by 13 users
Forked by 7 users
Languages   HTML 74.2% | JavaScript 25.8% | HTML 74.2% | JavaScript 25.8%
Find elsewhere
🌐
Echo Sierra Studio
esstudio.site › 2018 › 08 › 14 › json2xml.html
Converting JSON from and to XML in Javascript
August 13, 2018 - Creating a JSON to XML (and back) converter in javascript. Check out the code below.
🌐
Medium
medium.com › @tariibaba › javascript-convert-json-to-xml-80caf3148886
How to Convert JSON to XML in JavaScript | Medium
September 16, 2022 - We can use the xml-js library to ... 'xml-js';const jsonObj = { name: 'Garage', cars: [ { color: 'red', maxSpeed: 120, age: 2 }, { color: 'blue', maxSpeed: 100, age: 3 }, { color: 'green', maxSpeed: 130, age: 2 }, ], };const json ...
🌐
ASRock
tqdev.com › converting json to xml in javascript and php
Converting JSON to XML in JavaScript and PHP | TQdev
February 22, 2017 - function json2xml(json) { var a = JSON.parse(json) var c = document.createElement("root"); var t = function (v) { return {}.toString.call(v).split(' ')[1].slice(0, -1).toLowerCase(); }; var f = function (f, c, a, s) { c.setAttribute("type", t(a)); if (t(a) != "array" && t(a) != "object") { if (t(a) != "null") { c.appendChild(document.createTextNode(a)); } } else { for (var k in a) { var v = a[k]; if (k == "__type" && t(a) == "object") { c.setAttribute("__type", v); } else { if (t(v) == "object") { var ch = c.appendChild(document.createElementNS(null, s ?
🌐
GitHub
gist.github.com › ngs › 864302 › 1e3779051f718df039902bb860964e07fea3724d
json2xml.js · GitHub
json2xml.js · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ·
🌐
Ashismo
ashismo.github.io › java-misc › 2015 › 11 › 06 › XML2JSON-JSON2XML-In-Client-And-Server-Side
Xml2json Json2xml In Client And Server Side
November 6, 2015 - JSON2XML_XML2JSON zip(0kb) JSON2XML_XML2JSON · JsonToXmlToJson.html This file has jquery implementation to convert JSON o XML and vice versa. <html> <head> <script src="jquery.min.js"></script> <script src="x2js.js"></script> <script type="text/javascript"> function convertToJSON() { var input = $('textarea#input').val(); var x2js = new X2JS(); var json = JSON.stringify(x2js.xml_str2json(input)) $('textarea#output').val(json); } function convertToXml() { var input = $('textarea#input').val(); var x2js = new X2JS(); var xml = x2js.json2xml_str($.parseJSON(input)); $('textarea#output').val(xml)
🌐
Esstudio
esstudio.site › json2xml
JSON2XML
A Simple to use JSON to XML and XML to JSON converter utility. You are free to use the code in your own codebase: obj2xml.js · Animated Css Icons by Wenting Zhang
🌐
CodeSandbox
codesandbox.io › examples › package › json2xml
json2xml examples - CodeSandbox
AboutSimple JavaScript Object to XML string converter.33,688Weekly Downloads · Latest version0.1.3 · License · External Links · github.com/estheban/node-json2xml · github.com/estheban/node-json2xml/issues ·
🌐
npm
npmjs.com › package › js2xmlparser
js2xmlparser - npm
September 20, 2022 - Parses JavaScript objects into XML. Latest version: 5.0.0, last published: 3 years ago. Start using js2xmlparser in your project by running `npm i js2xmlparser`. There are 472 other projects in the npm registry using js2xmlparser.
      » npm install js2xmlparser
    
Published   Sep 20, 2022
Version   5.0.0
Author   Michael Kourlas
🌐
GitHub
github.com › mikeludemann › json2xml
GitHub - mikeludemann/json2xml: Convert JSON to XML with JavaScript · GitHub
Convert JSON to XML with JavaScript. Contribute to mikeludemann/json2xml development by creating an account on GitHub.
Author   mikeludemann
🌐
Npm
npm.io › search › keyword:json2xml
Json2xml | npm.io
Fast XML to Javascript data (and vise versa) converter and filter. Written in C++ using Expat SAX parser. xmljsjsondatacdataxml2jsonxml2jsxml2datadata2xmljson2xml2.5.1 • Published 8 years ago · This module converts any object into an XML · jsjs2xmljs2htmljsonjson2xmljson2htmlobjectobj2xmlobj2htmlxml1.0.7 • Published 4 years ago · Convierte un objeto en xml · json2xmljsontoxmljson to xmljson 2 xml1.0.4 • Published 6 years ago ·