I have an XML file with number of Records with Hebrew content and after I read It I want to save some of the Records that satisfied special condition to new XML file, but when I wrote to this new file, the Hebrew content convert to Gibberish like this:
<record>
...
<datafield tag="100" ind1=" " ind2=" ">
<subfield code="a">אבדי, אהרן בן צבי</subfield>
<subfield code="9">heb</subfield>
</datafield>
...
</record>
Here is part of my code:
let writers = ['marcxml', 'iso2709', 'json', 'text'].map(type => Marc.stream(fs.createWriteStream('results\\Short Stories.' + type), type));
...
writers.forEach((writer) => writer.write(record));
...
writers.forEach(writer => writer.end());
The example of how to read and write from XML file with Marc21 encoding is taken from here: https://www.npmjs.com/package/marcjs
Note: I tried to add "utf-8" encoding but it didn't work.