2005-01-02, 06:48 AM
ok this question is for kingarglye (or anyone else who knows). im trying to write a method to read in a itunes xml file, which looks something like
<files>
<key>
<artist></artist>
<filename></filename>
</key>
</files>
so i cant use .getchildnodes for each Key node. which well is the only way i know to iterate thru a xml file.
so i have to test, if key = tracks. then read thru the <dict> and then key again then the dict again, then filename. just with the multiple key and dict tags makes this hard. like icant use
foreach xmlnode in getnode("dict/dict".childnodes
blah blah blah
since the key is outside the dict tags.
after i have all the songs in a sorted array, theres another tag below which is <key>playlists</key>
which is similar to the tracks one, just refer to keys is all.
now does anyone know how the best way to read thru one of these files and build up this sorted array, once i have that method, the playlist method shud be just an alteration on that one.
cheers. reven.
[b Wrote:Quote[/b] ]<?xml version="1.0" encoding="UTF-8"?>which i will store two values in a sortedarray. Key=35 which will be the key (dah), and object will be the file string. but since itunes doesnt use something like
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1...">
<plist version="1.0">
<dict>
<key>Major Version</key><integer>1</integer>
<key>Minor Version</key><integer>1</integer>
<key>Application Version</key><string>4.6</string>
<key>Music Folder</key><string>file://localhost/E:/MP3s/</string>
<key>Library Persistent ID</key><string>B4B76FD9C797EE78</string>
<key>Tracks</key>
<dict>
<key>35</key>
<dict>
<key>Track ID</key><integer>35</integer>
<key>Name</key><string>Caramel Prisoner</string>
<key>Artist</key><string>Air</string>
<key>Album</key><string>10,000HZ Legend</string>
<key>Genre</key><string>Electronic</string>
<key>Kind</key><string>MPEG audio file</string>
<key>Size</key><integer>4770296</integer>
<key>Total Time</key><integer>298109</integer>
<key>Track Number</key><integer>11</integer>
<key>Date Modified</key><date>2004-01-19T19:20:45Z</date>
<key>Date Added</key><date>2003-10-17T17:51:51Z</date>
<key>Bit Rate</key><integer>128</integer>
<key>Sample Rate</key><integer>44100</integer>
<key>Play Count</key><integer>2</integer>
<key>Play Date</key><integer>-1112527749</integer>
<key>Play Date UTC</key><date>2004-11-04T18:59:07Z</date>
<key>Location</key><string>file://localhost/E:/MP3s/Air/10,000HZ%20Legend/11%20Caramel%20Prisoner.mp3/</string>
<key>File Folder Count</key><integer>4</integer>
<key>Library Folder Count</key><integer>1</integer>
</dict>
<files>
<key>
<artist></artist>
<filename></filename>
</key>
</files>
so i cant use .getchildnodes for each Key node. which well is the only way i know to iterate thru a xml file.
so i have to test, if key = tracks. then read thru the <dict> and then key again then the dict again, then filename. just with the multiple key and dict tags makes this hard. like icant use
foreach xmlnode in getnode("dict/dict".childnodes
blah blah blah
since the key is outside the dict tags.
after i have all the songs in a sorted array, theres another tag below which is <key>playlists</key>
which is similar to the tracks one, just refer to keys is all.
now does anyone know how the best way to read thru one of these files and build up this sorted array, once i have that method, the playlist method shud be just an alteration on that one.
cheers. reven.