txml.transformStream (offset, parseOptions?)
- offset optional you to set short before the first item.
usually files begin with something like "
" so the offset need to be before the first item starts so that between that item and the offset is no "<" character. alternatively, pass a string, containing this preamble. - options optional, similar to the parse methods options. return transformStream.
const xmlStream = fs.createReadStream('your.xml')
.pipe(txml.transformStream());
for await(let element of xmlStream) {
// your logic here ...
}
The transform stream is great, because when your logic within the processing loop is slow, the file read stream will also run slower, and not fill up the RAM memory. For a more detailed explanation read here