0

Possible Duplicate:
How to display images from an xml file in UI Image View

i have an xml file , there are number of images in subcategory i want to display all the images in a "Image View" and the "Image View" will be in scroll view as u scroll the images should keep loading . i am having difficulty in coding . The following code gives me the url links but i am having difficulties in displaying the images on 'Image View" which can be scrollable using "ScrollView". I am also showing the xml file ,where it shows one of the product

/////// XML File ////

<product>
        <product_name>HRC Classic Pin Collector Bag Blk &#x2013; Hard Rock</product_name>
        <url>http://rockshop.hardrock.com/PinsCollectibles/Pins/Product/HRC Classic Pin Collector Bag Blk/?src=sli</url>
        <image>http://rockshop.hardrock.com/ProductImages/HRC Classic Pin Collector Bag Blk.1.jpg?w=177</image>
        <large_image>http://rockshop.hardrock.com/ProductImages/HRC Classic Pin Collector Bag Blk.1.jpg?w=350</large_image>
        <front_image>http://rockshop.hardrock.com/ProductImages/HRC Classic Pin Collector Bag Blk.1.jpg?w=80</front_image>
        <product_number>HRC Classic Pin Collector Bag Blk</product_number>
        <availability>1</availability>
        <long_des>HRC Classic Pin Collector Bag Blk</long_des>
        <launch_date>4/15/2011 10:49:54 AM</launch_date>
        <price>40</price>
        <category>Pins &amp; Collectibles</category>
        <sub_category>Pins</sub_category>
    </product>

here is the code

-(IBAction)downloadImages:(id)sender
{
    NSData *data = [NSData dataWithContentsOfFile:@"pathOfURL"];
    NSError *error = nil;
    GDataXMLDocument *document = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error];
    NSError *err=nil;
    NSArray *nodes = [document nodesForXPath:@"/product_list/product[category = \"Pins & Collectibles\"]/image" error:&err]; 
    NSMutableArray *array =[[NSMutableArray alloc]initWithCapacity:[nodes count]];

    for(int i=0;i<[nodes count]; i++)
    {
        [array addObject:(NSString *)[[(NSString *)[[(NSString *)[[[NSString stringWithFormat:@"%@",[nodes objectAtIndex:i]] componentsSeparatedByString:@"{"] objectAtIndex:1] componentsSeparatedByString:@"<image>"] objectAtIndex:1] componentsSeparatedByString:@"</image>"] objectAtIndex:0] ]; 
    }

    NSLog(@"%@",array);

}

NSLog(@"%@",array); it is showing all the images url in the output console i just need to display them on UIImage in nib file , i am not able to do that so when u click a button all the images should display in a scroll view.

Community
  • 1
  • 1
raptor85
  • 125
  • 2
  • 4
  • 12

1 Answers1

0

Using the SDWebManager library might help you. https://github.com/rs/SDWebImage

This will help with async download of the urls, then you can use the imageView setImageWithURL: method.

elprl
  • 1,940
  • 25
  • 36