XML Plist parsing

The command line utility drutil can read an audio CD and extract song title, performer, composer info from CD’s that are encoded with CD text. DRUTIL creates an xml list formatted as a plist.

I haven’t been able to figure out how to use system events or Satimage XML & Property List osax to extract performer and title info from the plist. I need to put the performer and title info into lists for further processing, so that I can create readable documents I can send to my clients.

The documentation I’ve been able to find is either sparse or written for people very familiar with xml. Terms and nomenclature varies widely between xml parsing utilities and tutorials on xml.

I tried following the Satimage p-list tutorial http://www.satimage.fr/software/en/smile/xml/plist_tutorial.html but got stuck on the command “PlistType the_plist”. The example plist shows “dictionary” but the plist I’m working with shows “array”, and once I reach this point, I don’t know where to proceed.

Here’s an example of a cd text listing from drutil: Any advice on how to extract performer and title info from all tracks would be greatly appreciated.

<?xml version="1.0" encoding="UTF-8"?> Properties DRCDTextCFStringEncodingKey 66049 DRCDTextCharacterCodeKey 0 DRCDTextCopyrightAssertedForNamesKey 0 DRCDTextCopyrightAssertedForSpecialMessagesKey 0 DRCDTextCopyrightAssertedForTitlesKey 0 DRCDTextLanguageKey en DRCDTextNSStringEncodingKey 5 Tracks DRCDTextDiscIdentKey Shanachie SH-5775 DRCDTextGenreCodeKey 23 DRCDTextPerformerKey Leela James DRCDTextSizeKey AAELABYMAQEBAQMBAAAAAAAADgM6AAAAAAAAAAkAAAAA AAAA DRCDTextTitleKey Let's Do It Again DRCDTextPerformerKey Leela James DRCDTextTitleKey Clean Up Woman DRCDTextPerformerKey Leela James DRCDTextTitleKey Miss You DRCDTextPerformerKey Leela James DRCDTextTitleKey It's A Man's Man's Man's World DRCDTextPerformerKey Leela James DRCDTextTitleKey Baby I'm Scared of You DRCDTextPerformerKey Leela James DRCDTextTitleKey You Know How To Love Me DRCDTextPerformerKey Leela James DRCDTextTitleKey I Want to Know What Love Is DRCDTextPerformerKey Leela James DRCDTextTitleKey Nobody Wants You When You're Down and Out DRCDTextPerformerKey Leela James DRCDTextTitleKey I Try DRCDTextPerformerKey Leela James DRCDTextTitleKey I'd Rather Be With You DRCDTextPerformerKey Leela James DRCDTextTitleKey Simply Beautiful DRCDTextPerformerKey Leela James DRCDTextTitleKey Let's Do It Again

Hi,

try something like this


set {titleList, performerList} to {{}, {}}
set plistFile to (choose file) as text
tell application "System Events"
	tell property list file plistFile
		set allTracks to property list items of property list item 1 of property list item 1 of contents
		repeat with aTrack from 2 to count allTracks
			tell item aTrack of allTracks
				set end of titleList to value of property list item "DRCDTextTitleKey"
				set end of performerList to value of property list item "DRCDTextPerformerKey"
			end tell
		end repeat
	end tell
end tell

the result is in the two lists titleList and performerList

Stefan,

Many thanks. Never in my wildest dreams would I have thought that the answer would be in:
“set allTracks to property list items of property list item 1 of property list item 1 of contents”

I see it, and it works, but I still don’t understand how the syntax works. Like many things having to do with xml.