Last active
May 11, 2019 08:34
-
-
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/
This file contains 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
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