Support allowEmpty xmlbuilder in renderOpts
xml2js seems to pass through everything but the allowEmpty to the render options of xmlbuilder.
var xmlString = root.end({
pretty: true,
indent: ' ',
newline: '\n',
allowEmpty: false
});
...in our specific case we needed to control the allowEmpty parameter, as we have a system that takes in XML that does not allow for self-closing tags, but requires all elements to be submitted even when empty.
Seems like it would be a very easy fix, but I have no experience with CoffeeScript.
Also would love to have this functionality!
Passing in your own value for renderOpts when creating the xml2js.Builder works.
const builder = new xml2js.Builder({renderOpts: { 'pretty': true, 'indent': ' ', 'newline': '\n', allowEmpty: true }});
The docs don't mention this and it isn't listed as a default value in defaults.coffee, but as it passes renderOpts straight into .end() you're free to use whichever options are available in xmlbuilder at your resolved version.
Mentioned as spacebeforeslash was only added in v9.0.2 and xml2js only requires ~9.0.1.