Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nalp2010

macrumors member
Original poster
Dec 23, 2008
51
0
I'm new to programming/ OS X/XML so this question may sound dumb ... :rolleyes:


I have some XML data that looks like this -

Code:
<MyDocument>
<file subject="MyData" date="1228948010">

<segments>
			<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>
</segments>
</file>
</MyDocument>

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. :)
 

Nalp2010

macrumors member
Original poster
Dec 23, 2008
51
0
Just for any other beginners out there the solution to getting the attribute was -

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

:)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.