Simple XML Attribute Question

Discussion in 'Mac Programming' started by Nalp2010, Dec 23, 2008.

  1. Nalp2010 macrumors member

    Dec 23, 2008
    I'm new to programming/ OS X/XML so this question may sound dumb ... :rolleyes:

    I have some XML data that looks like this -

    <file subject="MyData" date="1228948010">
    			<segment bytes="362415" number="1">2008121023265016-dol@herecom</segment>
    			<segment bytes="362397" number="1">2008121023265343-dol@herecom</segment>
    			<segment bytes="362394" number="1">2008121023344097-dol@herecom</segment>
    What I'm trying to find is some example code (Cocoa) that very simply shows how to obtain the attributes, and print them out, for the segment entries e.g. bytes, number. I've tried to make sense of the Apple example but, being a novice, it's not clicking for me. Thanks in advance. :)
  2. kainjow Moderator emeritus


    Jun 15, 2000
  3. Nalp2010 thread starter macrumors member

    Dec 23, 2008
    Just for any other beginners out there the solution to getting the attribute was -

    int bytes=[[[aElement attributeForName:@"bytes"] stringValue] integerValue];

Share This Page