我了解到 iTunes XML 文件实际上是一个 plist,而不是尝试解析原始 XML,我可以使用属性列表。
我可以访问“曲目”部分,但无法执行任何简单的操作,例如提取曲目名称。诚然,我有点磕磕绊绊,但这是我到目前为止得到的代码:
tell application "System Events"
tell property list file property_file
tell contents
set my_tracks to value of property list item "Tracks"
repeat with t in my_tracks
set theName to value of property list item "Name" of t
display dialog theName
end repeat
end tell
end tell
end tell
关于我做错了什么的任何指示?
如果有帮助,请示例 XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.
com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Major Version</key><integer>1</integer>
<key>Minor Version</key><integer>1</integer>
<key>Application Version</key><string>9.0.2</string>
...
<dict>
<key>2471</key>
<dict>
<key>Name</key><string>Check The Rhime</string>
<key>Artist</key><string>A Tribe Called Quest</string>
...
</dict>
<key>2473</key>
<dict>
<key>Name</key><string>A Short History of Nearly Everyth
ing (Unabridged), Part 1</string>
<key>Artist</key><string>Bill Bryson</string>
...
</dict>