https://github.com/yamadapc/create-xml-ls
Another JS object to XML converter
https://github.com/yamadapc/create-xml-ls
Last synced: 10 days 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 (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-02-02T18:40:28.000Z (over 9 years ago)
- Last Synced: 2025-05-02T15:43:02.754Z (22 days ago)
- Language: LiveScript
- Size: 21.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# create-xml-ls [](http://travis-ci.org/yamadapc/create-xml-ls)
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