Created
September 7, 2016 14:59
-
-
Save tmanolat/8d81a09dfa98849afe4996a1b870256f to your computer and use it in GitHub Desktop.
node.js convert a json file to xml
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
var fs = require('fs'); | |
var xml2js = require('xml2js'); | |
var builder = new xml2js.Builder(); | |
var content = fs.readFileSync('data.json'); | |
var o = JSON.parse(content); | |
var res = []; | |
o.forEach(function(r){ | |
res.push(r); | |
}); | |
var xml = builder.buildObject(res); | |
fs.writeFileSync('out.xml', xml); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment