Instantly share code, notes, and snippets.

Embed
What would you like to do?
NodeJS XML to JSON using XML2JS https://embarkcode.com/nodejs-xml-to-json/
var xml2js = require('xml2js');
var xml = '<root>Hello world!</root>'
xml2js.parseString(xml, function (err, result) {
console.log(result.root); // Output: Hello world!
var json = JSON.stringify(result);
console.log(json); // Output: {"root":"Hello world!"}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment