Create xml with strings and concatenation.
npm install --save strxml
tag(el, [attributes], contents)
tagClose(el, attributes)
encode(str)
attr(attributes)
var tag = require('strxml').tag;
tag('Layer',
tag('StyleName', 'style-' + i) +
tag('Datasource', {
name: 'layer-' + i,
srs: WGS84
}));