Last active
June 5, 2019 13:32
-
-
Save AndersDJohnson/10166033 to your computer and use it in GitHub Desktop.
xml2js-as-promised
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 Q = require('q'); | |
var xml2js = require('xml2js'); | |
module.exports = function (input) { | |
var deferred = Q.defer(); | |
var parser = new xml2js.Parser(); | |
parser.parseString(input, function (err, stdout, stderr) { | |
if (err) { | |
return deferred.reject(err); | |
} | |
return deferred.resolve(stdout); | |
}); | |
return deferred.promise; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment