For some reason, iTunes decided to use non-standard XML formats with its files ... so it's hard for me to read it with SimpleXMLElement ...
ITunes XML Example:
<?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>10.1.1</string> <key>Features</key><integer>5</integer> <key>Show Content Ratings</key><true/> <key>Music Folder</key><string>file://localhost/D:/iTunes/Bob%20Russell%20Sermons/iTunes%20Media/</string> <key>Library Persistent ID</key><string>B8EB1073DB45BBA1</string> <key>Tracks</key> <dict> <key>290</key> <dict> <key>Track ID</key><integer>290</integer> <key>Name</key><string>01-03 Good News</string> <key>Artist</key><string>Bob Russell</string> <key>Album</key><string>Not in Series</string> <key>Grouping</key><string>Gospel, Decision Day, Salvation, Sin, Commandments, Mercy, Grace, Jesus Christ, Crucifixion, Resurrection, Justice, Hope</string> <key>Genre</key><string>Speech</string> <key>Kind</key><string>MPEG audio file</string> <key>Size</key><integer>18140686</integer> <key>Total Time</key><integer>1774132</integer> <key>Year</key><integer>1999</integer> <key>Date Modified</key><date>2010-09-09T17:41:58Z</date> <key>Date Added</key><date>2011-01-18T19:31:43Z</date> <key>Bit Rate</key><integer>80</integer> <key>Sample Rate</key><integer>44100</integer> <key>Comments</key><string>John 3:16-21; Light has come into the world, but men loved darkness; Romans 1:20; gather you as a mother hen gather chicks;1 Corinthians 15:19</string> <key>Artwork Count</key><integer>1</integer> <key>Persistent ID</key><string>7B3B348BF9BB95CE</string> <key>Track Type</key><string>File</string> <key>Location</key><string>file://localhost/D:/iTunes/Bob%20Russell%20Sermons/Sermons/1999/01-03%20Good%20News.mp3</string> <key>File Folder Count</key><integer>3</integer> <key>Library Folder Count</key><integer>1</integer> </dict>
Exit via SimpleXML:
SimpleXMLElement Object ( [key] => Array ( [0] => Track ID [1] => Name [2] => Artist [3] => Album [4] => Genre [5] => Kind [6] => Size [7] => Total Time [8] => Year [9] => Date Modified [10] => Date Added [11] => Bit Rate [12] => Sample Rate [13] => Comments [14] => Artwork Count [15] => Persistent ID [16] => Track Type [17] => Location [18] => File Folder Count [19] => Library Folder Count ) [integer] => Array ( [0] => 332 [1] => 6419273 [2] => 1415262 [3] => 1991 [4] => 32 [5] => 22050 [6] => 1 [7] => 3 [8] => 1 ) [string] => Array ( [0] => 07-07 Thank God for America [1] => Bob Russell [2] => No Series [3] => Speech [4] => MPEG audio file [5] => Isaiah 40:13-26 [6] => 94BD9A32817C24F1 [7] => File [8] => file:
I'm having problems because the keys of the array are incompatible if the information is missing. On one speech can have 8 integer values, on the other - 5 .... What is the best way to read this data?
Webnet
source share