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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:21:56+00:00 2026-06-16T18:21:56+00:00

I am Parsing an XML file from a URL using an NSXMLParser , the

  • 0

I am Parsing an XML file from a URL using an NSXMLParser, the items that I parse are added to an array that a UITableView loads its data from. Among other things I am parsing titles for events and dates that those events take place on. These items are parsed and added to an array called stories. My goal is to have the title of an event be the main text for each cell in my TableView and the date be a subtitle. The title of each event does not need to be formatted (i.e. if the XML file reads: “Event One” then that is what should be displayed) I am successful with this using this method:

(title being the title of an item in the XML, stories being the array that the TableView loads its data from.)

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

    static NSString *MyIdentifier = @"MyIdentifier";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]
        initWithStyle:UITableViewCellStyleSubtitle
        reuseIdentifier:MyIdentifier];
    }

    // Set up the cell
    NSUInteger storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
    cell.textLabel.text = [[stories objectAtIndex: storyIndex] objectForKey: @"title"];

    return cell;
}

However I do need to format all of the dates I parse, I do so with an NSDateFormatter, I am satisfied with the format of the dates after the NSDateFormatter has done its job. If i did not need to format the dates I could use:

cell.detailTextLabel.text = [[stories objectAtIndex: storyIndex] objectForKey: @"isodate"];

to achieve my goal. Once the NSDateFormatter has done its job I have a variable (a NSMutableString) called currentDate with the string value for my formatted dates, using the console I can see that this yields the desired result for every item in the XML. When I use:

cell.textLabel.text = currentDate;

I end up with every cell in my table having the date of the final item in the XML file (granted it looks nice is formatted correctly). I have tried moving my methods around to no avail. If you wouldn’t mind pointing me in the right direction, I need to know how to include the value of my variable currentDate in the subtitle text of a UITableView in a way in which the title of an item and the date of the item in a cell correspond with one another.

  • 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-16T18:21:57+00:00Added an answer on June 16, 2026 at 6:21 pm

    A couple of thoughts:

    1. Regarding your date problem, it sounds like you’re storing the date in a single instance variable called currentDate. And given that you didn’t share that code, I gather you’re not doing that in cellForRowAtIndexPath, but rather, perhaps in your parser, or something like that. Unfortunately, that would give every cell in the table the date for the last row you parsed). You should either

      • call your date formatting right in cellForRowAtIndexPath (or, better, call a method that does your date formatting), specifically grab [[stories objectAtIndex: storyIndex] objectForKey: @"isodate"], format it, and set detailTextLabel.text accordingly; or

      • rather than storing the formatted date in a single currentDate variable, add an dictionary key for the formatted date and store it in the mutable dictionary with everything else you parsed from the XML (e.g. read in isodate, format a string and save it back to the same dictionary with a unique key, maybe formattedDate).

    2. NSUInteger storyIndex = indexPath.row; is a more common syntax if you’re grabbing the news item associated with the given row of the tableview.

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

Sidebar

Related Questions

I am using feedparser for parsing from XML file.But I couldn't parse <geo:lat> ,
I am parsing xml file from url(in code below), using file_get_contents() function, and simpleXML,
I am parsing xml file from server using xmlParser in Android. When i print
iam developing one application.In that iam using the xml parsing.That xml file contain the
Hii it's easy for me to parse a XML file from a web URL
I'm parsing XML from URL. What changes has been made to parse same XML
I am fetching the some data from the server using XML parsing that is
basically I am parsing a xml file and retrieving certain elements from that xml
I'm parsing an xml file from an url and it displays the content correctly.here
I'm using NSXMLParser to parse a small XML file containing information about videos. One

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.