count nodes in XML file with Cocoa

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

  1. wesg macrumors regular


    Jan 2, 2008
    Toronto, ON
    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


    Mar 8, 2007
    Cambridge, MA
    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:

  3. kainjow Moderator emeritus


    Jun 15, 2000
    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