iTunes XML Parser

Discussion in 'Mac Programming' started by mmmdreg, Dec 27, 2004.

  1. macrumors 65816

    mmmdreg

    Joined:
    Apr 14, 2002
    Location:
    Sydney, Australia
    #1
    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?
     
  2. macrumors 6502a

    mj_1903

    Joined:
    Feb 3, 2003
    Location:
    Sydney, Australia
    #2
    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".
     
  3. thread starter macrumors 65816

    mmmdreg

    Joined:
    Apr 14, 2002
    Location:
    Sydney, Australia
  4. macrumors 6502a

    mj_1903

    Joined:
    Feb 3, 2003
    Location:
    Sydney, Australia
    #4
    Did you look in the documentation? It is quite obvious. :)

    Methods like:

    Code:
    - (id)objectForKey:(NSString *)aString
    for NSDictionary's or

    Code:
    - (id)objectAtIndex:(int)anIndex
    for NSArray's.
     
  5. macrumors newbie

    Joined:
    Nov 24, 2005
    #5
    is there an easy way to do this using java instead of obj-c?
     
  6. Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #6
    Using the now unsupported 'Java bridge'. Check the Apple documentation on using cocoa from java.
     
  7. macrumors 65816

    devman

    Joined:
    Apr 19, 2004
    Location:
    AU
    #7

Share This Page