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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:19:23+00:00 2026-05-17T00:19:23+00:00

I am really struggling on this. I have an XML feed: <?xml version=1.0 encoding=ISO-8859-1?>

  • 0

I am really struggling on this. I have an XML feed:

<?xml version="1.0" encoding="ISO-8859-1"?>
<data>
    <date>
        <name>27/9/10</name>
        <event>
            <title>Event 1</title>
            <more>Copy in here</more>
        </event>
    </date>
    <date>
        <name>04/10/10</name>
        <event>
            <title>Event 1</title>
            <more>Copy in here</more>
        </event>
        <event>
            <title>Second Event</title>
            <more>Copy in here</more>
        </event>
    </date>
</data>

I can manage to parse the xml with:

- (void)parseXMLFileAtURL:(NSString *)URL {
    sections = [[NSMutableArray alloc] init];
    items = [[NSMutableArray alloc] init];

    NSURL *xmlURL = [NSURL URLWithString:URL];
    rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
    [rssParser setDelegate:self];
    [rssParser parse];
}

- (void)parserDidStartDocument:(NSXMLParser *)parser {

}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{

    currentElement = [elementName copy];

    if ([elementName isEqualToString:@"event"]) {
        currentTitle = [[NSMutableString alloc] init];
        currentSummary = [[NSMutableString alloc] init];
    }

    if ([elementName isEqualToString:@"date"]) {
        item = [[NSMutableDictionary alloc] init];
    currentSection = [[NSMutableString alloc] init];
    }
}

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

    if ([elementName isEqualToString:@"date"]) {
        [item setObject:[NSNumber numberWithInt:itemsCount] forKey:@"itemsCount"];
        [item setObject:currentSection forKey:@"name"];
        [items addObject:[item copy]];

        itemsCount = 0;
    }

    if ([elementName isEqualToString:@"event"]) {
        [item setObject:currentTitle forKey:@"title"];
        [item setObject:currentSummary forKey:@"more"];
        [items addObject:[item copy]];

        itemsCount = itemsCount + 1;
    }
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
    if ([currentElement isEqualToString:@"name"]) {
        [currentSection appendString:string];
    } else if ([currentElement isEqualToString:@"title"]) {
        [currentTitle appendString:string];
    } else if ([currentElement isEqualToString:@"more"]) {
        [currentSummary appendString:string];
    }
}

- (void)parserDidEndDocument:(NSXMLParser *)parser {

    [self.progressView.view removeFromSuperview];
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    [dataTable reloadData];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    if ([sections count] == 0) {
        NSString * path = @"http://www.campuscloud.co.uk/_dev/calendar.xml";
        [self parseXMLFileAtURL:path];
    }

}

But when I try and display this in my table it all goes wrong when I display more than two events for the one date. I want the date to show as a section header and the events to be displayed below.

Any help on this welcome…

  • 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-17T00:19:24+00:00Added an answer on May 17, 2026 at 12:19 am

    Hey buddy.. I don’t know if I understood coorect, but let’s go..

    You can create a dictionary of arrays..

    NSMutableDictionary *dates = [NSMutableDictionary alloc];
    NSMutableArray *events = [NSMutableArray alloc];
    

    in the array you will insert all event of one date..

    [events addObject:@"event 1"];
    

    in the dictionary you will insert the array of events with tha date as key

    [dates setobject:events forKey:@"01/01/2010"];
    

    whenever the parser find a new date, a new array should be created (I mean, the values are new.. don’t append the array, clean it.. but you don’t need to create a brand new array)

    of course that you have to make some changes on the parser to identify the dates and etc, but it’s not a big deal.

    in your table each section is one key from your dictionary.. so the number of sections is the number of items on the dictionary.. and the values inside the section is the array of each date..

    I hope it helps..

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

Sidebar

Related Questions

I am really struggling with this. I have decided to switch to Passenger after
I'm really struggling with this query. I have 4 tables (http://oberto.co.nz/db-sql.png): Invoice_Payement, Invoice, Client
I'm really struggling to get this to work in xcode 4. I have one
I am trying to read the following xml stream but am really struggling. <channelSnapshot
I have been struggling with this NHibernate issue for hours. I extensively researched on
Still really struggling with this and appear to be going round in circles. I
I am trying to get a date picker working and I am really struggling
Ok so this might not be the best title but I am struggling with
I am really struggling with this one. Below is an image of a layout
I am writing my first Android application, and I have been struggling with this

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.