更新时间:2023-01-16 14:07:50
你能不能简单地做一些类似的事情:
Could you not simply do something like:
fs.readFile('content.xml', 'utf-8', function (err, data){
if(err) console.log(err);
parseString(data, function(err, result){
if(err) console.log(err);
var json = result;
console.log(json);
var needle = 'This text must change';
// Convert the result into a string, replace all instances of
// needle with some text, then parse the json string back into
// an object
json = JSON.parse(JSON.stringify(result).replace(needle, SOME_REPLACEMENT_TEXT_HERE));
...
});