I am writing my first bigger AppleScript and as I am usually developing TypeScript, I decided to use the JavaScript version of AppleScript. I need to read and parse an XML file.
Apple has an Example for that on their documentation, however the documentation only has an example in the AppleScript syntax, not in the JavaScript syntax:
How do I actually do the given example in JavaScript?
I can read the file as a String, but that does not help me as I need to traverse the XML-tree.
Advertisement
Answer
In the end I used webpack and an npm-package for parsing XML files to JSON: https://www.npmjs.com/package/fast-xml-parser
my code example is here:
https://github.com/kellertobias/rekordbox-to-music-playlists/blob/master/src/load-rekordbox.ts