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 8256925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:01:54+00:00 2026-06-08T02:01:54+00:00

I’m parsing an xml file from an url and it displays the content correctly.here

  • 0

I’m parsing an xml file from an url and it displays the content correctly.here is my xml file

<gold>
<price>
<title>22 K Gold - SGD $69.50</title>
</price>
<price>
<title>24 K Gold - SGD $62.50</title>
</price>
</gold>

now its displays each content in cell like the image below

image

Now i need to display 22kgold in a cell and SGD $69.50 in a cell.and also the next element same.And also to print these values in two labels.

here is my code in .m file

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSMutableArray *tableArray = [[NSMutableArray alloc]init];

    NSData *xmlData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:@"http://www.p41tech.com/img/application/android/server/kamala/goldprice.xml"]];
    tbxml = [[TBXML alloc]initWithXMLData:xmlData];


    TBXMLElement * root = tbxml.rootXMLElement;

    if (root)
    {
        TBXMLElement * elem_PLANT = [TBXML childElementNamed:@"price" parentElement:root];

        while (elem_PLANT !=nil)
        {
            TBXMLElement * elem_BOTANICAL = [TBXML childElementNamed:@"title" parentElement:elem_PLANT];
            NSString *botanicalName = [TBXML textForElement:elem_BOTANICAL];
            [tableArray addObject:botanicalName];
            elem_PLANT = [TBXML nextSiblingNamed:@"price" searchFromElement:elem_PLANT];
        }      
    }

    label1.text=@"%@",botanicalName;
    label2.text=@"%@",elem_PLANT;
}

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [tableArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    cell.backgroundView = [ [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"download.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ]autorelease];   
    cell.textLabel.backgroundColor=[UIColor clearColor];
    cell.textLabel.text = [tableArray objectAtIndex:indexPath.row];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;


    tableView.backgroundColor=[UIColor clearColor];
    return cell;
}

My label contents are not displayed and i need to separate string in each cell by ‘-‘.Please guide me..

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-06-08T02:01:57+00:00Added an answer on June 8, 2026 at 2:01 am

    You probably meant:

    label1.text = [NSString stringWithFormat:@"%@", botanicalName];
    label2.text = [NSString stringWithFormat:@"%@", elem_PLANT];
    

    otherwise you were assigning the string “%@” into the labels, and ignoring botanicalName and elem_PLANT.

    To separate the rows into two parts, you can use the following inside your tableView:cellForRowAtIndexPath: method:

    NSArray *parts = [[tableArray objectAtIndex:indexPath.row] componentsSeparatedByString:@" - "];
    NSString *item = [parts objectAtIndex:0];
    NSString *price = [parts objectAtIndex:1];
    

    You can then either:

    1. Use one of the UITableViewCellStyleSubtitle, UITableViewCellStyleValue1, or UITableViewCellStyleValue1 cell styles, and assign the item and price variables to the cell.textLabel.text and cell.detailTextLabel.text properties, or

    2. you could add a custom cell view, and assign them to your own labels within that view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an XML file, the creators of it stuck in a bunch social
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text

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.