How iTunes Uses XML

Do you ever wonder how iTunes can put your songs on multiple playlists without having to duplicate your mp3 files? iTunes uses XML. Otherwise, you would have to duplicate all of those audio files to unnecessarily take up storage space on your computer. Within your iTunes folder there is an XML file named “iTunes Music Library.” It is within this file that all of your music library and playlists are organized. This is an abridged display of how it is organized:

1. First, there is the XML Declaration:

<?xml version="1.0" encoding="UTF-8"?>

 

2. Next, the Data Type Definition (DTD) – iTunes DTD Details

3.Third, there is the doctype ( “plist” ) which is defined in the DTD.

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

4. Here we find the structure of a <dict > with an array of keys, each followed by the value of the key. at the end of the file you will find the closing </dict> tag. How the contents of <dict></dict> are structured was also defined in the DTD ( <!ELEMENT dict (key, %plistObject;)*> ). This top-level <dict> contains the metadata for the playlist as a whole:

<dict>

<key>Major Version</key><integer>1</integer>
<key>Minor Version</key><integer>1</integer>
<key>Application Version</key><string>10.4.1</string>
<key>Features</key><integer>5</integer>
<key>Show Content Ratings</key><true/>
<key>Music Folder</key><string>file://localhost/Volumes/My%20Book/MP3s/</string>
<key>Library Persistent ID</key><string>str1nG0fNumb3rs</string>
<key>Tracks</key>

 

5. It also contains sub-level <dict> sections for each audio file, given a unique <key> number, which in this case is 9512.

<dict>

<key>9512</key>

 

6. This <key> has its own sub-level <dict> with a key followed by a value.

<dict>
<key>Track ID</key><integer>9512</integer>
<key>Name</key><string>That Dang-old Goat Fell Over</string>
<key>Artist</key><string>HowStuffWorks.com</string>
<key>Album</key><string>Stuff You Should Know</string>
<key>Genre</key><string>Podcast</string>
<key>Kind</key><string>MPEG audio file</string>
<key>Size</key><integer>10093669</integer>
<key>Total Time</key><integer>1675128</integer>
<key>Year</key><integer>2011</integer>
<key>Date Modified</key><date>2011-03-29T01:00:06Z</date>
<key>Date Added</key><date>2011-03-29T01:00:06Z</date>
<key>Bit Rate</key><integer>48</integer>
<key>Sample Rate</key><integer>22050</integer>
<key>Release Date</key><date>2011-03-24T16:20:47Z</date>
<key>Artwork Count</key><integer>1</integer>
<key>Persistent ID</key><string>10173BCFAEA60A89</string>
<key>Track Type</key><string>File</string>
<key>Podcast</key><true/>
<key>Location</key><string>file://localhost/Volumes/My%20Book/MP3s/Podcasts/Stuff%20You%20Should%20Know/That%20Dang-old%20Goat%20Fell%20Over.mp3</string>
<key>File Folder Count</key><integer>4</integer>
<key>Library Folder Count</key><integer>1</integer>
</dict>

 

7. Playlists are structured, after an initial <key></key>, by <array><dict><key>:

<key>Playlists</key>

<array>
<dict>
<key>Name</key><string>Library</string>
<key>Master</key><true/>
<key>Playlist ID</key><integer>9822</integer>
<key>Playlist Persistent ID</key><string>78C92BDCC11BD3A0</string>
<key>Visible</key><false/>
<key>All Items</key><true/>
<key>Playlist Items</key>

 

8. Sub-level arrays have the same <array><dict><key> structure

<array>

<dict>
<key>Track ID</key><integer>2574</integer>
</dict>
<dict>
<key>Track ID</key><integer>1518</integer>
</dict>
<dict>
<key>Track ID</key><integer>1520</integer>
</dict>
<dict>
<key>Track ID</key><integer>1522</integer>
</dict>

 

9. And finally all of our closing tags

</array>
</dict>

</plist>

One thought on “How iTunes Uses XML

  1. Pingback: iTunes Data Type Definition (DTD) - Intelligent Writing Intelligent Writing

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>