count nodes in XML file with Cocoa

Discussion in 'Mac Programming' started by wesg, Dec 16, 2008.

  1. wesg macrumors regular

    wesg

    Joined:
    Jan 2, 2008
    Location:
    Toronto, ON
    #1
    I'm working on an application that analyzes the iTunes XML file, and I'm also considering one that does something similar for the iPhoto library. What is the best way to determine the number of tracks/photos in the different libraries?

    WHen I open either file with Property List editor I see the correct value, but when I count nodes with Cocoa, I get more than the actual value. Any suggestions for traversing a particular node inside the XML file?
     
  2. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #2
    In general, this is accomplished with XQuery and XPath. Cocoa provides an interface this standard via the NSXML Core Foundation class.

    You can read about it here:

    NSXML
     
  3. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #3
    Aren't they just property lists? So you should be able to walk through it via NSDictionary/NSArray, etc. Maybe your counting is off :)
     

Share This Page