teethboyes
New Member
This question can be a duplicated one. But I was unable to find a proper answer for my issue. I have following xml file downloading from a server. \[code\]<INCIDENTTYPES> <INCIDENT FORMNAME="first" TEXT="First incident"> <TYPE>Type1</TYPE> <TYPE>Type2</TYPE> <TYPE>Type3 Tag</TYPE> <TYPE>Type4 Tag</TYPE> <LOCATION>Council</LOCATION> <LOCATION>Domestic</LOCATION> <LOCATION>Commercial</LOCATION> </INCIDENT> <INCIDENT FORMNAME="second" TEXT="Second incident"> <TYPE>Second type</TYPE> <TYPE>Second/first type</TYPE> <TYPE>Second3</TYPE> <LOCATION>Council</LOCATION> <LOCATION>Domestic</LOCATION> <LOCATION>Commercial</LOCATION> </INCIDENT></INCIDENTTYPES>\[/code\]I am using RaptureXML to parse the xml file and parsing can be done as follows.\[code\]RXMLElement *rootXML = [RXMLElement elementFromXMLData:self.connectionData]; [rootXML iterate"INCIDENT" usingBlock: ^(RXMLElement *incidents) { if([[incidents attribute"FORMNAME"] isEqualToString"first"]){ NSArray *listArray = [NSArray array]; listArray = [incidents children"TYPE"]; IncidentData *iData = http://stackoverflow.com/questions/15746878/[[IncidentData alloc] init]; [iData.type setValue:listArray forKey"type"]; NSData *data = http://stackoverflow.com/questions/15746878/[NSKeyedArchiver archivedDataWithRootObject:iData]; [self.userDefault setObject:data forKey"firstObject"]; } }\[/code\]The IncidentData class as follows.\[code\] #import "IncidentData.h" @implementation IncidentData - (id)initWithCoderNSCoder *)aDecoder{ if (self = [super init]) {//self.type is an array self.type = [aDecoder decodeObjectForKey"type"]; } return self; } - (void)encodeWithCoderNSCoder *)aCoder{ [aCoder encodeObject:self.type forKey"type"]; } @end\[/code\]I am trying to load data as following.\[code\]NSData *dd = [self.userDefault objectForKey"firstObject"];IncidentData *items = (IncidentData *)[NSKeyedUnarchiver unarchiveObjectWithData:dd];NSArray *typeArray = [items.type objectAtIndex:0];NSLog(@"Incident type : %@", typeArray);\[/code\]But typeArray is null. Summary: I am trying to parse a remote xml file and save the values on to the disk and use later stage of the app. Can you please help me on this ?