node-xml
node-xml copied to clipboard
Should not readFile an entire file.
fs.readFile, defeats the purpose for a SaxParser. This is loading the entire xml into memory and causes errors when loading large xml files.
SaxParser.prototype.parseFile = function(filename) { //This function will only work in the node.js environment. var fs = require('fs'); var that = this; fs.readFile(filename, function (err, data) { that.parseString(data); }); }
Ah, this explains why I'm getting silent failures for a 1GB XML document and another one that is 100GB. Thanks.
The use of readFile is a policy choice that might be justifiable based on this project's goals, but failing silently instead of throwing an error is a bug.