var util = require('util'); var xml2js = require('xml2js'); var myxml = " \ \ \ 1 \ green \ \ \ 2 \ red \ \ \ 3 \ yellow \ \ " xml2js.parseString(myxml, function (e, r) { console.log(util.inspect(r, false, null)); console.log(new xml2js.Builder().buildObject(r)); });