Open ghost opened 3 years ago
I don't think this is the most elegant way to go about it. But I was able to get rid of theerror by parsing the string of xml.
let data = JSON.parse(JSON.stringify(myRequest.responseText))
data = parseString(data, (err, result) => {
console.dir(result);
if (err) {
console.log(err);
}
})
This should work out of the box, since xml2js has now code to remove the byte order mark before parsing.
Originally posted by @Leonidas-from-XIV in https://github.com/Leonidas-from-XIV/node-xml2js/issues/345#issuecomment-264904146
But it doesn't seem that way for other characters. To reproduce the error:
Drop in the script provided in #345:
And you'll get the output:
Notice the XML is parsed as expected when opened in Firefox and Chrome: https://habd.as/post/show-latest-posts-github-profile/assets/index.xml
I tried replacing the first character (
0x1F
) from the file using a hex editor and running the parsing script (above) again but the issue persists. I suppose this may be an issue in the SAX parser—but I'm unable to identify the root cause.