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

  • SEARCH
  • Home
  • 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 6746365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:18:50+00:00 2026-05-26T12:18:50+00:00

I have become able to parse the xml url using TBXML parser. parsed data

  • 0
  1. I have become able to parse the xml url using TBXML parser.

  2. parsed data will be into a NSMutableArray named records.

  3. Here is the code….

    if ([[TBXML elementName:element] isEqualToString:@"order"]) {
        NSLog(@"xml element checking");
        TBXMLElement *id = [TBXML childElementNamed:@"id" parentElement:element];
        TBXMLElement *status = [TBXML childElementNamed:@"status" parentElement:element];
        TBXMLElement *date = [TBXML childElementNamed:@"date" parentElement:element];
        TBXMLElement *by = [TBXML childElementNamed:@"by" parentElement:element];
        TBXMLElement *total = [TBXML childElementNamed:@"total" parentElement:element];
    
    
        [records addObject:[NSArray arrayWithObjects:
                            [TBXML textForElement:id],
                            [TBXML textForElement:status],
                            [TBXML textForElement:date],
                            [TBXML textForElement:by],
                            [TBXML textForElement:total],nil]];   
    
  4. Now these records data will be display in the tableview cell,so number of rows will be as same as records array size.

  5. now in my tableview there is five UILabel.every label will display the attribute value of the records array value.

    6.i can display the value of the attribute first time until scroll the tableview but my problem is when i start scrolling in my UITableview then value starts to display in wrong cell.

  6. Here the tableview code…

      - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *MyIdentifier = @"MyIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15.0];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow.png"]];
    cell.accessoryView = imageView;
    cell.accessoryType = UITableViewCellSelectionStyleNone;
    tableView.separatorColor = [UIColor clearColor];
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
    cellView = [[[UIView alloc] initWithFrame:CGRectMake(5,8,290, 120)] autorelease];
    cellView.backgroundColor = [UIColor clearColor];
    cellView.tag =10;
    [cell.contentView addSubview:cellView];
    
    imgView = [[UIImageView alloc] initWithFrame:CGRectMake(2, 40, 48, 48)];
    imgView.image = [UIImage imageNamed:@"productbox.png"];
    imgView.layer.borderColor = [UIColor blackColor].CGColor;
    imgView.layer.borderWidth = 2.0;
    imgView.tag = 5;
    [cellView addSubview:imgView];
    
    CGRect idLabelRect = CGRectMake(65, 0, 190, 18);
    idLabel = [[[UILabel alloc] initWithFrame:idLabelRect] autorelease];
    idLabel.textAlignment = UITextAlignmentLeft;
    idLabel.textColor = [UIColor blackColor];
    idLabel.font = [UIFont systemFontOfSize:12];
    idLabel.backgroundColor = [UIColor redColor];
    idLabel.layer.borderColor = [UIColor grayColor].CGColor;
    idLabel.tag = 0;
    
    CGRect statusRect = CGRectMake(65, 22, 190, 22);
    statusLabel = [[[UILabel alloc] initWithFrame:statusRect] autorelease];
    statusLabel.textAlignment = UITextAlignmentLeft;
    statusLabel.textColor = [UIColor blackColor];
    statusLabel.font = [UIFont systemFontOfSize:12];
    statusLabel.backgroundColor = [UIColor greenColor];
    statusLabel.layer.borderColor = [UIColor grayColor].CGColor;
    statusLabel.tag = 1;
    
    CGRect orderDateRect = CGRectMake(65, 48, 190, 22);
    orderDate = [[[UILabel alloc] initWithFrame:orderDateRect] autorelease];
    orderDate.textAlignment = UITextAlignmentLeft;
    orderDate.textColor = [UIColor blackColor];
    orderDate.font = [UIFont systemFontOfSize:12];
    orderDate.backgroundColor = [UIColor grayColor];
    orderDate.layer.borderColor = [UIColor grayColor].CGColor;
    orderDate.tag = 2;
    
    CGRect byRect = CGRectMake(65, 75, 190, 22);
    byLabel = [[[UILabel alloc] initWithFrame:byRect] autorelease];
    byLabel.textAlignment = UITextAlignmentLeft;
    byLabel.textColor = [UIColor blackColor];
    byLabel.font = [UIFont systemFontOfSize:12];
    byLabel.backgroundColor = [UIColor yellowColor];
    byLabel.layer.borderColor = [UIColor grayColor].CGColor;
    byLabel.tag = 3;
    
    CGRect totalRect = CGRectMake(65, 98, 190, 22);
    totalLabel = [[[UILabel alloc] initWithFrame:totalRect] autorelease];
    totalLabel.textAlignment = UITextAlignmentLeft;
    totalLabel.textColor = [UIColor blackColor];
    totalLabel.font = [UIFont systemFontOfSize:12];
    totalLabel.backgroundColor = [UIColor cyanColor];
    totalLabel.layer.borderColor = [UIColor grayColor].CGColor;
    totalLabel.tag = 4;
    
    [cellView addSubview:idLabel];
    [cellView addSubview:statusLabel];
    [cellView addSubview:orderDate];
    [cellView addSubview:byLabel];
    [cellView addSubview:totalLabel];
    }
      x = [records count];
      //NSLog(@" total number of row: %d",x);
        if(y<x){
    if(y == indexPath.section){
        cellView = (UIView *)[cell.contentView viewWithTag:10];
        idLabel = (UILabel *)[cellView viewWithTag:0];
        statusLabel = (UILabel *)[cellView viewWithTag:1];
        orderDate = (UILabel *)[cellView viewWithTag:2];
        byLabel = (UILabel *)[cellView viewWithTag:3];
        totalLabel = (UILabel *)[cellView viewWithTag:4];
        imgView = (UIImageView *)[cellView viewWithTag:5];
    
        NSLog(@"the value of y: %d",y);
        NSLog(@"the value of indexpath.section: %d",indexPath.section);
        idLabel.text = [NSString stringWithFormat:@"Order Id: %@",[[records objectAtIndex:y] objectAtIndex:0]];
        statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[records objectAtIndex:y] objectAtIndex:1]];
        orderDate.text = [NSString stringWithFormat:@"Date: %@",[[records objectAtIndex:y] objectAtIndex:2]];
        byLabel.text = [NSString stringWithFormat:@"By: %@",[[records objectAtIndex:y] objectAtIndex:3]];
        totalLabel.text = [NSString stringWithFormat:@"Total: %@",[[records objectAtIndex:y] objectAtIndex:4]];
        y++;
    }
    }
    return cell;
     }
    

    Thats mean first time when table loads then value are displaying in right cell but when i start scrolling value are not displaying right cell.

Last couple of days i am being fade up with this problem so please anybody know what is solution then inform me as soon as possible…

Thanks in Advance.

  • 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-05-26T12:18:51+00:00Added an answer on May 26, 2026 at 12:18 pm

    i have got my answer it was very silly problem……may be it will helpful for someone…

    Here is the code…i have just change the tableview delegate…

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
       static NSString *MyIdentifier = @"MyIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
        cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15.0];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
        UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow.png"]];
        cell.accessoryView = imageView;
        cell.accessoryType = UITableViewCellSelectionStyleNone;
        tableView.separatorColor = [UIColor clearColor];
        tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    
        cellView = [[[UIView alloc] initWithFrame:CGRectMake(5,8,290, 120)] autorelease];
        cellView.backgroundColor = [UIColor clearColor];
        cellView.tag =10;
        [cell.contentView addSubview:cellView];
    
        imgView = [[UIImageView alloc] initWithFrame:CGRectMake(2, 40, 48, 48)];
        imgView.image = [UIImage imageNamed:@"productbox.png"];
        imgView.layer.borderColor = [UIColor blackColor].CGColor;
        imgView.layer.borderWidth = 2.0;
        imgView.tag = 5;
        [cellView addSubview:imgView];
    
        CGRect idLabelRect = CGRectMake(65, 0, 190, 18);
        idLabel = [[[UILabel alloc] initWithFrame:idLabelRect] autorelease];
        idLabel.textAlignment = UITextAlignmentLeft;
        idLabel.textColor = [UIColor blackColor];
        idLabel.font = [UIFont systemFontOfSize:12];
        idLabel.backgroundColor = [UIColor clearColor];
        idLabel.layer.borderColor = [UIColor grayColor].CGColor;
        idLabel.tag = 0;
    
        CGRect statusRect = CGRectMake(65, 22, 190, 22);
        statusLabel = [[[UILabel alloc] initWithFrame:statusRect] autorelease];
        statusLabel.textAlignment = UITextAlignmentLeft;
        statusLabel.textColor = [UIColor blackColor];
        statusLabel.font = [UIFont systemFontOfSize:12];
        statusLabel.backgroundColor = [UIColor clearColor];
        statusLabel.layer.borderColor = [UIColor grayColor].CGColor;
        statusLabel.tag = 1;
    
        CGRect orderDateRect = CGRectMake(65, 48, 190, 22);
        orderDate = [[[UILabel alloc] initWithFrame:orderDateRect] autorelease];
        orderDate.textAlignment = UITextAlignmentLeft;
        orderDate.textColor = [UIColor blackColor];
        orderDate.font = [UIFont systemFontOfSize:12];
        orderDate.backgroundColor = [UIColor clearColor];
        orderDate.layer.borderColor = [UIColor grayColor].CGColor;
        orderDate.tag = 2;
    
        CGRect byRect = CGRectMake(65, 75, 190, 22);
        byLabel = [[[UILabel alloc] initWithFrame:byRect] autorelease];
        byLabel.textAlignment = UITextAlignmentLeft;
        byLabel.textColor = [UIColor blackColor];
        byLabel.font = [UIFont systemFontOfSize:12];
        byLabel.backgroundColor = [UIColor clearColor];
        byLabel.layer.borderColor = [UIColor grayColor].CGColor;
        byLabel.tag = 3;
    
        CGRect totalRect = CGRectMake(65, 98, 190, 22);
        totalLabel = [[[UILabel alloc] initWithFrame:totalRect] autorelease];
        totalLabel.textAlignment = UITextAlignmentLeft;
        totalLabel.textColor = [UIColor blackColor];
        totalLabel.font = [UIFont systemFontOfSize:12];
        totalLabel.backgroundColor = [UIColor clearColor];
        totalLabel.layer.borderColor = [UIColor grayColor].CGColor;
        totalLabel.tag = 4;
    
        [cellView addSubview:idLabel];
        [cellView addSubview:statusLabel];
        [cellView addSubview:orderDate];
        [cellView addSubview:byLabel];
        [cellView addSubview:totalLabel];
    }
    
    
    cellView = (UIView *)[cell.contentView viewWithTag:10];
    idLabel = (UILabel *)[cellView viewWithTag:0];
    statusLabel = (UILabel *)[cellView viewWithTag:1];
    orderDate = (UILabel *)[cellView viewWithTag:2];
    byLabel = (UILabel *)[cellView viewWithTag:3];
    totalLabel = (UILabel *)[cellView viewWithTag:4];
    imgView = (UIImageView *)[cellView viewWithTag:5];
    
        //here is my changed of code
        idLabel.text = [NSString stringWithFormat:@"Order Id: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:0]];
        statusLabel.text = [NSString stringWithFormat:@"Status: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:1]];
        orderDate.text = [NSString stringWithFormat:@"Date: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:2]];
        byLabel.text =[NSString stringWithFormat:@"By: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:3]];
        totalLabel.text =[NSString stringWithFormat:@"Total: %@",[[records objectAtIndex:indexPath.section] objectAtIndex:4]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have become accustomed to using TryParse for attempting to parse unknown types: Dim
Please refer to this post. I have become able to configure my web.config file
I have become accustomed to using F6 to compile the current document. A third-party
Lately I have become a huge fan of XSL, XPath and XML, but I've
I have been using Django for web-development, and have become quite fond of that
I have what will become an 'external' activemq server I'd like grails to be
I am trying to build a parser with Bison/Yacc to be able to parse
I have become pretty fluent in a few different languages now, but I seem
Within the last year I have become addicted to subversion. I am an only
I am learning about SOAP implementation and have become somewhat confused regarding the appropriate

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.