PDA

View Full Version : iTunes XML Parser




mmmdreg
Dec 27, 2004, 11:49 PM
I'm a total script kiddie when it comes to cocoa so I was wondering if someone can shove me in the right direction regarding parsing the iTunes xml file for data on all the songs so that I can use them for something else?



mj_1903
Dec 28, 2004, 01:56 AM
NSDictionary ;)

Location of the iTunes Music Library file is nearly always ~/Music/iTunes/iTunes Music Library.xml.

To load this:

[NSDictionary dictionaryWithContentsOfFile:[@"~/Music/iTunes/iTunes Music Library.xml" stringByExpandingTildeInPath]];

Open the xml file in property list editor to see the layout, but the main keys that you will want are "Tracks" and "Playlists".

mmmdreg
Dec 28, 2004, 02:47 AM
hehe but how do I take those values out? =)

mj_1903
Dec 28, 2004, 02:50 AM
hehe but how do I take those values out? =)

Did you look in the documentation? It is quite obvious. :)

Methods like:

- (id)objectForKey:(NSString *)aString

for NSDictionary's or

- (id)objectAtIndex:(int)anIndex

for NSArray's.

sicojola
Nov 24, 2005, 05:24 AM
NSDictionary ;)

Location of the iTunes Music Library file is nearly always ~/Music/iTunes/iTunes Music Library.xml.

To load this:

[NSDictionary dictionaryWithContentsOfFile:[@"~/Music/iTunes/iTunes Music Library.xml" stringByExpandingTildeInPath]];



is there an easy way to do this using java instead of obj-c?

caveman_uk
Nov 24, 2005, 05:55 AM
Using the now unsupported 'Java bridge'. Check the Apple documentation on using cocoa from java.

devman
Nov 26, 2005, 01:00 AM
is there an easy way to do this using java instead of obj-c?

JAXP. http://java.sun.com/webservices/jaxp/index.jsp