iphone - Parsing XML to get multiple values -
i'm retrieving data xml:
<appmetrics versionname="1.1.0" startdate="2013-04-16" metric="activeusersbyday" groupby="dayofyear" enddate="2013-04-18" country="us" version="1.0" generateddate="4/19/13 10:10 am"> <day value="6" date="2013-04-16"/> <day value="4" date="2013-04-17"/> <day value="2" date="2013-04-18"/> </appmetrics>
i have been successful simpler xmls if instead:
<appmetrics versionname="1.1.0" startdate="2013-04-16" metric="activeusersbyday" groupby="dayofyear" enddate="2013-04-18" country="us" version="1.0" generateddate="4/19/13 10:10 am"> <day value="6"/> <day value="4"/> <day value="2"/> </appmetrics>
how extract both day value , date under same single element? i've done in past search element copy string, there multiple pieces doesnt work. have make array instead? or there way take day value , date separately?
you should use nsxmlparser
. in delegate callback
parser:didstartelement:namespaceuri:qualifiedname:attributes:
you can find attributes (like value
, date
) in attributes dictionary.
edit
parsing easy. create parser data, set self delegate , start parsing. maintain mutable array read in.
see nsxmlparser reference , nsxmlparserdelegate protocol.
if need more help, go this question many links tutorials.
Comments
Post a Comment