xml-js
xml-js copied to clipboard
how to use createReadStream instead of readFileSync
I was wondering how it is possible to use createReadStream instead of readFileSync? I am trying to read an xml which is 500MB so node is running out of heap memory so I need to read the file in chunk instead.
let json = convert.xml2js( fs.readFileSync(
entities.xml), { instructionHasAttributes: true, compact: true, spaces: 4, reversible: true, } );
when I change fs readFileSync to fs.createReadStream I get the following error:
UnhandledPromiseRejectionWarning: Error: Text data outside of root node.