node-xml
node-xml copied to clipboard
stream with multiple input
Hi, I have multiple input to xml. When I close on of the input stream, closing other has no effect. I dont get the closing tag for the last element
kml = xml.element({ _attr: { xmlns: 'http://www.opengis.net/kml/2.2'} });
doc = xml.element({})
stream = xml([{kml: kml}, {Document: doc}], {declaration: true})
stream.on 'data', (chunk) ->
console.log(chunk);
doc.close()
kml.close()
And here is the output
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
</Document>
Closign tag for kml is missing
I think I found the issue here. The first element should be the one that should end the stream when closing
if (i + 1 === input.length)
last = end;
add(value, last);
should be
if (i == 0)
last = end;
add(value, last);