module.exports = function(xml, _options) {
var parser = new expat.Parser('UTF-8');
parser.on('startElement', startElement);
parser.on('text', text);
parser.on('endElement', endElement);
obj = currentObject = {};
ancestors = [];
options = {
object: false,
reversible: false
};
for (var opt in _options) {
options[opt] = _options[opt];
}
if (!parser.parse(xml)) {
throw new Error('There are errors in your xml file: ' + parser.getError());
}
if (options.object) {
return obj;
}
return JSON.stringify(obj);
};