Skip to content
Advertisement

Open XML file in AppleScript with JavaScript syntax

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:

https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/WorkwithXML.html#//apple_ref/doc/uid/TP40016239-CH67-SW1

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

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement