Reading into plist files
Hi,
I'm building an app that relies heavily on reading plist files. I've got the basics down using System Events, for example:
tell application "System Events"
set plistFile to "/Library/Preferences/com.domain.prefs.plist"
set returnVal to (value of property list item "MyValue" of property list file plistFile)
display dialog returnVal
end tell
To extract from the following plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MyValue</key>
<string>1000</string>
</dict>
</plist>
But of course I need to read further into plist files, count the number of re-occurrences of certain items and so on. For example, if I wanted to read into the following plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MyValue</key>
<key>ArrayInfo</key>
<array>
<dict>
<key>Bool</key>
<true/>
<key>Value1</key>
<string>1000</string>>
</dict>
<dict>
<key>Bool</key>
<true/>
<key>Value1</key>
<string>4000</string>>
</dict>
</array>
</dict>
</plist>
How can I extract, for example, the number of records within the array and then create an AS list of each re-occurrence of 'Value1' or 'bool'?
Any help on this or any links to good tutorials will be much appreciated.
Many thanks.
I'm building an app that relies heavily on reading plist files. I've got the basics down using System Events, for example:
tell application "System Events"
set plistFile to "/Library/Preferences/com.domain.prefs.plist"
set returnVal to (value of property list item "MyValue" of property list file plistFile)
display dialog returnVal
end tell
To extract from the following plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MyValue</key>
<string>1000</string>
</dict>
</plist>
But of course I need to read further into plist files, count the number of re-occurrences of certain items and so on. For example, if I wanted to read into the following plist file:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>MyValue</key>
<key>ArrayInfo</key>
<array>
<dict>
<key>Bool</key>
<true/>
<key>Value1</key>
<string>1000</string>>
</dict>
<dict>
<key>Bool</key>
<true/>
<key>Value1</key>
<string>4000</string>>
</dict>
</array>
</dict>
</plist>
How can I extract, for example, the number of records within the array and then create an AS list of each re-occurrence of 'Value1' or 'bool'?
Any help on this or any links to good tutorials will be much appreciated.
Many thanks.
MacBook Pro, Mac OS X (10.5.6)