Skip to content

Instantly share code, notes, and snippets.

@AbuzerAsif
Last active May 11, 2019 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbuzerAsif/6a8ddcd9b0f87037f2f0e6b6c6c15b40 to your computer and use it in GitHub Desktop.
Save AbuzerAsif/6a8ddcd9b0f87037f2f0e6b6c6c15b40 to your computer and use it in GitHub Desktop.
NodeJS XML to JSON using XML2JS https://embarkcode.com/nodejs-xml-to-json/
const xml2js = require('xml2js');
const xml = '<root>Hello world!</root>'
xml2js.parseString(xml, function (err, result) {
console.log(result.root); // Output: Hello world!
const 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