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`
- Host: GitHub
- URL: https://github.com/jstransformers/jstransformer-xml2js
- Owner: jstransformers
- License: mit
- Created: 2015-04-03T18:45:31.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2023-07-26T17:56:38.000Z (almost 3 years ago)
- Last Synced: 2025-01-21T20:15:41.103Z (over 1 year ago)
- Language: JavaScript
- Homepage: http://npm.im/jstransformer-xml2js
- Size: 71.3 KB
- Stars: 1
- Watchers: 7
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE.md
Awesome Lists containing this project
README
# jstransformer-xml2js
[xml2js](https://github.com/Leonidas-from-XIV/node-xml2js) support for [JSTransformers](http://github.com/jstransformers).
[](https://travis-ci.org/jstransformers/jstransformer-xml2js)
[](https://codecov.io/gh/jstransformers/jstransformer-xml2js)
[](http://david-dm.org/jstransformers/jstransformer-xml2js)
[](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