xml2js support for JSTransformers.
npm install jstransformer-xml2js
var xml = require('jstransformer')(require('jstransformer-xml'));
var opts = {};
var fixture = '<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>Example Feed</title></feed>';
var promise = xml.renderAsync(fixture, opts);
promise.then(function(data) {
console.log(JSON.parse(data.body));
//=> { feed:
// { '$': { xmlns: 'http://www.w3.org/2005/Atom' },
// title: [ 'Example Feed' ] } }
});
var promise = xml.renderFileAsync('./path/to/config.xml', opts);
promise.then(function(data) {
console.log(JSON.parse(data.body));
//=> { feed:
// { '$': { xmlns: 'http://www.w3.org/2005/Atom' },
// title: [ 'Example Feed' ] } }
});
MIT