An open API service indexing awesome lists of open source software.

https://github.com/jstransformers/jstransformer-xml2js

XML support for JS Transformers, transform XML to JSON. Using `xml2js`
https://github.com/jstransformers/jstransformer-xml2js

Last synced: 10 months ago
JSON representation

XML support for JS Transformers, transform XML to JSON. Using `xml2js`

Awesome Lists containing this project

README

          

# jstransformer-xml2js

[xml2js](https://github.com/Leonidas-from-XIV/node-xml2js) support for [JSTransformers](http://github.com/jstransformers).

[![Build Status](https://img.shields.io/travis/jstransformers/jstransformer-xml2js/master.svg)](https://travis-ci.org/jstransformers/jstransformer-xml2js)
[![Coverage Status](https://img.shields.io/codecov/c/github/jstransformers/jstransformer-xml2js/master.svg)](https://codecov.io/gh/jstransformers/jstransformer-xml2js)
[![Dependency Status](https://img.shields.io/david/jstransformers/jstransformer-xml2js/master.svg)](http://david-dm.org/jstransformers/jstransformer-xml2js)
[![NPM version](https://img.shields.io/npm/v/jstransformer-xml2js.svg)](https://www.npmjs.org/package/jstransformer-xml2js)

## Installation

npm install jstransformer-xml2js

## API

```js
var xml = require('jstransformer')(require('jstransformer-xml'));
var opts = {};

var fixture = 'Example 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' ] } }
});
```

## License

MIT