Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yamadapc/create-xml-ls
Another JS object to XML converter
https://github.com/yamadapc/create-xml-ls
Last synced: about 1 month ago
JSON representation
Another JS object to XML converter
- Host: GitHub
- URL: https://github.com/yamadapc/create-xml-ls
- Owner: yamadapc
- License: mit
- Created: 2013-11-01T06:08:04.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-02T18:40:28.000Z (almost 9 years ago)
- Last Synced: 2024-12-24T11:57:47.123Z (about 1 month ago)
- Language: LiveScript
- Size: 21.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# create-xml-ls [![Build Status](https://secure.travis-ci.org/yamadapc/create-xml-ls.png?branch=master)](http://travis-ci.org/yamadapc/create-xml-ls)
![](logo.png)Another JS object to XML converter
*Today, only node 0.10 is supported due to a build fail of libxmljs in node
0.11*## Instalation
```npm install create-xml-ls```
## Example
### Javascript
#### createXml(obj[, options])
```javascript
var createXml = require('create-xml-ls');createXml({
something: {
is: 'very',
ugly: {
$attr: {
IMHO: 'it sucks'
}
but: 'sometimes we have to live with it'
}
}
}, { pretty: true });
/* =>very
sometimes we have to live with it
*/
```
Indentation is off by default, but can be toggled with ```options.pretty``` set
to true.The default attributes key is ```'$attr'```, but you can also use a custom one
by setting ```options.attributesKey``` to the desired key.
```javascript
createXml({
something:
is: {
attributes: {
'kind': 'of'
},
interesting: 'about this'
}
}, { pretty: true, attributesKey: 'attributes' );
/* =>
about this
*/
```There's also support for array properties.
```javascript
createXml({
arrayExample: {
sometimes: [
'I',
'had',
'to',
'do',
'this'
]
}
}, { pretty: true });
/* =>I
had
to
do
this*/}
```## License
Copyright (c) 2013 Pedro Yamada. Licensed under the MIT license.## Donations
Would you like to buy me a beer? Send bitcoin to 3JjxJydvoJjTrhLL86LGMc8cNB16pTAF3y