iTunes export to XML.

Anyone know how to export all user playlists to xml on the desktop?

Go to File menu and export.

I know that. I want to know how to do it in Applescript.

Open iTunes Music Library.xml and parse for Playlists?
UI Scripting?

I don’t want to parse the library. I want to get it through actual tell of the application iTunes.

iTunes doesn’t support that, so you’ll have to use UI scripting.

activate application "iTunes"

tell application "System Events"
	launch
	tell process "iTunes" to click menu item 11 of menu 1 of menu bar item 3 of menu bar 1
	keystroke return
	
	if (exists file ((path to desktop as Unicode text) & "Library.xml")) then
		delay 0.5
		-- overwrites existing file!
		keystroke space
	end if
end tell