79759455

Date: 2025-09-09 02:56:04
Score: 0.5
Natty:
Report link

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));
});

Reasons:
  • Blacklisted phrase (0.5): I need
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Langerz