i have an XML file as url where the file contains like this,
<Products>
<products id="1">
<name>product1</name>
<price>$150</price>
<img>http://www.myimage.com/Main_pic.png</img>
</products>
</Products>
Now using NSXMLParser i can retrieve the data and the image but after i get those data am not understanding how to store in NSMutableArray or NSDictionary. Also i tried to implement lazyloading asynchronous image download from Lazy Loading Table Images Asynchronous Downloading from Apple. But i failed to load the images. Do we have any alternative for aynchronous loading.
Kindly describe me in detail about,
- how to store a data retieved from url XML file in aysnchronous downloading.
- how to separate data and image.
- how to implement those in UIImage and data to view in iPhone.
EDITED
for better understanding i need the data and the image like below picture and not in the table view.

EDITED-2
By using the lazyloading parsing i modified according to my content here the code for your reference,
- (void)main{
self.workingArray = [NSMutableArray array];
self.workingPropertyString = [NSMutableString string];
NSXMLParser *parser = [[NSXMLParser alloc] initWithData:dataToParse];
[parser setDelegate:self];
[parser parse];
if (![self isCancelled]){
self.completionHandler(self.workingArray);}
self.workingArray = nil;
self.workingPropertyString = nil;
self.dataToParse = nil;}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
if ([elementName isEqualToString:@"Products"]){
self.workingEntry = [[egsLists alloc] init];}
storingCharacterData = [elementsToParse containsObject:elementName];}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
if (self.workingEntry){
if (storingCharacterData){
NSString *trimmedString = [workingPropertyString stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
[workingPropertyString setString:@""];
if ([elementName isEqualToString:sIDStr]){
self.workingEntry.ProductID = trimmedString;}
else if ([elementName isEqualToString:sImageStr]){
self.workingEntry.img = trimmedString;}}
else if ([elementName isEqualToString:@"Products"]){
[self.workingArray addObject:self.workingEntry];
self.workingEntry = nil;}}}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
if (storingCharacterData){
[workingPropertyString appendString:string];}}
take a
NSObjectClass sayDataClass// create objects for your data in
DataClass.hAndSynthesizethem inDataClass.mAfter That When You Need you can Retrive the Data From Array if you are Using
TableViewthen in your
CellForRowAtindexPathmethod use the following:You can Use LazyTableImages SampleCode from Apple for Loading Images.
http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Introduction/Intro.html
For Complete XML parsing See the Tutorial or use Below Code:
Source : http://www.theappcodeblog.com/2011/05/09/parsing-xml-in-an-iphone-app-tutorial/