xml2js.js / sax.js: Non-whitespace before first tag
Just in case this helps someone by coming up in google:
Error: Non-whitespace before first tag. Line: 0 Column: 1 Char: 'error parsing xml: Error: Non-whitespace before first tag.\\nLine: 0\\nColumn: 1\\nChar: '
When looking into the XML directly and testing it e.g. with an XML validator everything seems fine. Turns out the culprit is the so called Byte-Order-Mark (BOM), a 3byte "Zero width no-break space" unicode character which Windows systems automatically prepend to utf-8 files. When inspecting your file with a hex editor it shows up as hex "EFBBBF".
The following line (called before passing the data on to xml2js) fixed the issue:
var cleanedString = origString.replace("\\ufeff", "");