I found a solution to my issue.
I needed to update, npm, nodejs, fast-xml-parser. And the issue seems resolved with the following updated code.
const fs = require("fs");
const { XMLParser } = require("fast-xml-parser");
const options = {
ignoreAttributes: false,
attributeNamePrefix: '@_',
parseAttributeValue: true,
};
const parser = new XMLParser(options);
var tsx = "tilesheet.tsx";
var tsxExists = fs.readFileSync(tsx);
if (!tsxExists) {
console.error(tsx + " doesn't exist.");
}
fs.readFile(tsx, function(err, file2) {
if (err) {
console.error(err);
return;
}
var tsxdata = file2.toString();
console.log(file2.toString());
var jsonObj = parser.parse(tsxdata, options);
console.log(JSON.stringify(jsonObj));
});