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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:12:03+00:00 2026-05-22T18:12:03+00:00

I have a element that is repeating and i need to read it’s attributes

  • 0

I have a element that is repeating and i need to read it’s attributes and send them to the delegate

the xml is:

<special>
   <day date="22/04/2011" name="Easter Friday">Closed</day>
   <day date="23/04/2011" name="Easter Saturday">10:00-16:00</day>
   <day date="24/04/2011" name="Easter Sunday">Closed</day>
   <day date="25/04/2011" name="Anzac Day">13:00-17:00</day>
   <day date="26/04/2011" name="Easter Tuesday">09:00-18:00</day>
</special>

i only get to past the last attributes for date and name to the delegate and i know why is this happening but i dont know how to fix it. can someone help me

here is my objective C code

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
    attributes:(NSDictionary *)attributeDict {
if ([elementName isEqualToString:@"special"]) {
        storeAppDelegate.openingHoursSpecialDelegate = [[NSMutableArray alloc] init];
    }else if ([elementName isEqualToString:@"day"]) {
        openingHoursView = [[OpeningHoursView alloc] init];
        openingHoursView.name = [attributeDict objectForKey:@"name"];
        openingHoursView.date = [attributeDict valueForKey:@"date"];
      }
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if ([elementName isEqualToString:@"special"])
        return;
    if ([elementName isEqualToString:@"day"]){
        [storeAppDelegate.openingHoursSpecialDelegate addObject:openingHoursView];
        [openingHoursView release];
        openingHoursView = nil;     

    }   
}

openingHoursSpecialDelegate is a mutable array in the app delegate and OpeningHoursView is a NSObject that has name and date as strings in it in another class. They also get the value of the app delegate and it is also only the last read value for “date” and “name” attributes from the XML file .
I’m working with NSXML parser
so again my question is how to get “openingHoursView.name” and “openingHoursView.date” to write every value they get to openingHoursSpecialDelegate and not overwrite them as it happens now

  • 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-22T18:12:04+00:00Added an answer on May 22, 2026 at 6:12 pm

    I can’t find anything wrong with the code. I’ve put the above code into a small test project (with minor changes to make it run standalone), and it runs fine for me.

    Array (
    “Easter Friday, 22/04/2011”,
    “Easter Saturday, 23/04/2011”,
    “Easter Sunday, 24/04/2011”,
    “Anzac Day, 25/04/2011”,
    “Easter Tuesday, 26/04/2011” )

    Example project

    You’ll need to change the path I’ve hardcoded in the class test2AppDelegate, to point to a file containing the XML you posted above.

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

Sidebar

Related Questions

i have very simple problem. I need to create model, that represent element of
I have an element that is similar to a tag (because it has word-wrap:
I have a form element that contains multiple lines of inputs. Think of each
I have a form element that I want to address via javascript, but it
I have a div element that has an id and this div contains a
I have a file input element that needs to be cloned after the user
I have some AJAX work that brings across an additional form element that I
I have an element in my document that has a background color and image
I have an element with an onclick method. I would like to activate that
I'm trying to use XPath to find all elements that have an element in

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.