create-xml-ls
Another JS object to XML converter
Instalation
npm install create-xml-ls
Example
Javascript
createXml(obj[, options])
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 });
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.
createXml({
something:
is: {
attributes: {
'kind': 'of'
},
interesting: 'about this'
}
}, { pretty: true, attributesKey: 'attributes' );
There's also support for array properties.
createXml({
arrayExample: {
sometimes: [
'I',
'had',
'to',
'do',
'this'
]
}
}, { pretty: true });
}
License
Copyright (c) 2013 Pedro Yamada. Licensed under the MIT license.