objective c - iOS: NSXMLParser - A lot of attributes -


i know there lot of answers here , on google stuck since 3 days figuring out how handle problem. hope can give me advice.

all content in xml attribute. parse attributedict. trying handle attributes (void)parser:(nsxmlparser *)parser didstartelement.... , display them later in tableview.

i have put attributes nsmutablearray , want display device name , channels , value of datapoint. later change value of daterpoint button. not sure if best way trying. found post nspredicate. right way? lot in advance!

nsxmlparser delegates handling attributes

this code:

- (void)parser:(nsxmlparser *)parser didstartelement....   if(![elementname isequal:@"device"])         return;     name = [[nsmutablearray alloc] init];     nsstring * name = [attributedict objectforkey:@"name"];     [name addobject:name];      if(![elementname isequal:@"device"])         return;     namedatapoint = [[nsmutablearray alloc] init];     nsstring * datapoint = [attributedict objectforkey:@"ise_id"];     [namedatapoint addobject:datapoint];  ... 

and part of xml:

<statelist> <device name="fußbodenheizung" ise_id="1418" unreach="false" sticky_unreach="false" config_pending="false">  <channel name="hm-lc-sw4-dr meq0213526:1" ise_id="1443" visible="true" operate="true"> <datapoint name="bidcos-rf.meq0213526:1.state" type="state" ise_id="1447" value="false" valuetype="2" valueunit="" timestamp="1454260698" operations="7"/> </channel> <channel name="hm-lc-sw4-dr meq0213526:2" ise_id="1449" visible="true" operate="true"> <datapoint name="bidcos-rf.meq0213526:2.state" type="state" ise_id="1453" value="false" valuetype="2" valueunit="" timestamp="1454260785" operations="7"/> </channel> <channel name="hm-lc-sw4-dr meq0213526:3" ise_id="1455" visible="true" operate="true"> <datapoint name="bidcos-rf.meq0213526:3.state" type="state" ise_id="1459" value="false" valuetype="2" valueunit="" timestamp="1454260786" operations="7"/> </channel> <channel name="hm-lc-sw4-dr meq0213526:4" ise_id="1461" visible="true" operate="true"> <datapoint name="bidcos-rf.meq0213526:4.state" type="state" ise_id="1465" value="false" valuetype="2" valueunit="" timestamp="1454260786" operations="7"/> </channel> </device> <device name="hm-cc-rt-dn meq0807085" ....... 

assuming name , namedatapoint static, should not alloc init them in parser:didstartelement. doing erase previous data each time new device found.

if wan't keep allocation in parser:didstartelement lazily:

... if (!name) {   name = [[nsmutablearray alloc] init]; } ... 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -