Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:53:21+00:00 2026-06-09T06:53:21+00:00

I’m new to the iphone development, I’m using NSXML to parse and able to

  • 0

I’m new to the iphone development, I’m using NSXML to parse and able to display data in tableview, I also need to display image along with the text in the tableview.Prior to submitting this question I have searched over the internet and have found no solutions.,

The following is the code I’m using to parse and display data on table view

NSMutableString *currentNodeContent;
NSXMLParser *parser;
ImageView *currentImage;
bool isStatus;

ViewController *xmlParser;

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    ImageView *currentImage = [[xmlParser templates]objectAtIndex:indexPath.row];

    UITableViewCell *cell = [UITableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if(cell == nil)
    {

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

    CGRect nameLabelFrame = CGRectMake(55, 2, 250, 20);
    UILabel *namelabelF = [[UILabel alloc] initWithFrame:nameLabelFrame];
    namelabelF.tag = 0011;
    namelabelF.font = [UIFont boldSystemFontOfSize:12];
    namelabelF.text = @"Template Name :";
    namelabelF.textColor = [UIColor orangeColor];
    [cell.contentView addSubview:namelabelF];

    CGRect nameFrame = CGRectMake(165, 2, 250, 20);
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:nameFrame];
    nameLabel.tag = 0012;
    nameLabel.font = [UIFont boldSystemFontOfSize:12];
    [cell.contentView addSubview:nameLabel];

    CGRect imageFrame = CGRectMake(105, 20, 250, 13);
    UILabel *imageLabel = [[UILabel alloc]initWithFrame:imageFrame];
    imageLabel.tag = 0014;
    imageLabel.font = [UIFont systemFontOfSize:12];
    [cell.contentView addSubview:imageLabel];

    CGRect categoryFrameCreated = CGRectMake(45, 35, 250, 10);
    UILabel *categoryFrameCreatedLabel = [[UILabel alloc] initWithFrame:categoryFrameCreated];
    categoryFrameCreatedLabel.tag = 0015;
    categoryFrameCreatedLabel.font = [UIFont boldSystemFontOfSize:10];
    categoryFrameCreatedLabel.text = @"Category ;";
    categoryFrameCreatedLabel.textColor = [UIColor grayColor];
    [cell.contentView addSubview:categoryFrameCreatedLabel];

    CGRect categoryFrame = CGRectMake(105, 35, 250, 10);
    UILabel *categoryLabel = [[UILabel alloc] initWithFrame:categoryFrame];
    categoryLabel.tag = 0016;
    categoryLabel.font = [UIFont systemFontOfSize:10];
    [cell.contentView addSubview:categoryLabel];

    }

    UILabel *templateLabel = (UILabel *)[cell.contentView viewWithTag:0012];
    templateLabel.text = [currentImage templateName];

    UILabel *imgLabel = (UILabel *)[cell.contentView viewWithTag:0014];
    imgLabel.text = [currentImage imgPath];


    UILabel *categoryLabel = (UILabel *)[cell.contentView viewWithTag:0016];
    categoryLabel.text = [currentImage category];

    return cell;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 55;
}


#pragma mark -
#pragma mark Table view delegate


-(id) loadXMLByURL:(NSString *)urlString
{
    templates       = [[NSMutableArray alloc] init];
    NSURL *url      = [NSURL URLWithString:urlString];
    NSData  *data   = [[NSData alloc] initWithContentsOfURL:url];
    parser          = [[NSXMLParser alloc] initWithData:data];
    parser.delegate = self;
    [parser parse];

    return self;

}

- (void) parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
    currentNodeContent = (NSMutableString *) [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}

- (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
    if ([elementname isEqualToString:@"template_maste"]) 
    {
        currentImage = [ImageView alloc];
        isStatus = YES;
    }

    if ([elementname isEqualToString:@"Template_name"]) 
    {
        currentImage = [ImageView alloc];
        isStatus = YES;
    }


}

- (void) parser:(NSXMLParser *)parser didEndElement:(NSString *)elementname namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{

    if ([elementname isEqualToString:@"Template_name"]) 
    {
        currentImage.templateName = currentNodeContent;
    }  

    if ([elementname isEqualToString:@"img_path"]) 
    {
        currentImage.imgPath = currentNodeContent;
    }
    if ([elementname isEqualToString:@"Category"]) 
    {
        currentImage.category = currentNodeContent;
    }
    if ([elementname isEqualToString:@"template_maste"]) 
    {
        [self.templates addObject:currentImage];
        currentImage = nil;
        currentNodeContent = nil;
    }

}


- (void)viewDidLoad
{
    [super viewDidLoad];

    xmlParser = [[ViewController alloc] loadXMLByURL:@"http://www.okok.net/services/contacts.aspx?type=gettemplates1&category="];
}

*–xml file–***

<template_maste>
<img_id>249</img_id>
<img_path>http://www.okok.net/Templatehtml/small/249.jpg</img_path>
<html_path>/templatehtml/249.html</html_path>
<Added_date>2011-12-28T00:00:00-08:00</Added_date>
<Template_name>Happy New year 4</Template_name>
<Category>Seasonal</Category>
<Template_Status>1</Template_Status>
</template_maste>

I want to display the image from the img_path in the tableview

Any solutions would be appreciated..,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:53:22+00:00Added an answer on June 9, 2026 at 6:53 am

    I’m not sure what your trying to present in your table view cell, but if you want the image to be shown then you need to use UIImageView (now you just use a label to show the image URL)
    BTW ImageView is your model so it’s not a good idea to call it “view” i would change it to imageData and add a UIImage property to hold the actual image.
    So the same way you added a label to your cell, add the image view:

    UIImageView *imageView = nil;
    if(cell == nil) {
    
           cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    
           imageView = [[UIImageView alloc] initWithFrame:someFrame];
           imageView.tag = IMAGE_VIEW_TAG;
           [cell.contentView addSubview:imageView];  
    
           // ...
        }
    
        // now you need to configure this cell
        // first thing is to get the model for this cell
        ImageData *imageData = [[xmlParser templates]objectAtIndex:indexPath.row];  
    
        if (!imageData.image) {
           // we don't have the image yet in our model, so we need to fetch it from the
           // internet according to the image path. 
           // do it in a separate thread to not block the UI 
           dispatch_queue_t imgDownloaderQueue = dispatch_queue_create("imageDownloader", NULL);
           dispatch_async(imgDownloaderQueue, ^{
              NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString:imageData.imgPath]];
              UIImage *image = [UIImage imageWithData:imageData];
              [imageData release];
              dispatch_queue_t main_queue = dispatch_get_main_queue();
              dispatch_sync(main_queue, ^{
                 imageData.image = image;
    
                 // update UI 
                 [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                                              withRowAnimation:UITableViewRowAnimationNone];
              });
           });
           dispatch_release(imgDownloaderQueue);
        }
        else {
           // we already fetched the image, so we just update the image view
    
           imageView = (UIImageView *)[cell.contentView viewWithTag:IMAGE_VIEW_TAG];  
           imageView.image = imageData.image;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
In my XML file chapters tag has more chapter tag.i need to display chapters
i want to parse a xhtml file and display in UITableView. what is the
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.