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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:08:41+00:00 2026-05-29T05:08:41+00:00

I’m trying to parse the response from a web server. My parser does as

  • 0

I’m trying to parse the response from a web server.

My parser does as follows:

#import "XMLParser.h"
#import "AppDelegate.h"
#import "Child.h"

@implementation XMLParser

- (XMLParser *) initXMLParser {

     self = [super init];

    if(self)
    {
        appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    }
    return self;
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName 
    attributes:(NSDictionary *)attributeDict 
{
    if([elementName isEqualToString:@"GetKidsResult"])
    {
        // initialize the array
        if(!appDelegate.children)
        {
            appDelegate.children = [[NSMutableArray alloc] init];

        }

    }

    else if([elementName isEqualToString:@"a:KeyValueOfintKidf4KEWLbb"])
    {
        if(!aChild)
        {
        //Initialize the child.
            aChild = [[Child alloc] init];
        }
    }

    NSLog(@"Processing Element: %@", elementName);
}

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 

    if(!currentElementValue) 
    {
        currentElementValue = [[NSMutableString alloc] initWithString:string];
    }
    else
    {
        [currentElementValue appendString:string];
    }

}

-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
    //NSLog(@"El name: %@", elementName);

    if([elementName isEqualToString:@"GetKidsResult"])

        NSLog(@"end of xml");
        return;    

    if([elementName isEqualToString:@"a:KeyValueOfintKidf4KEWLbb"])
    {
        NSLog(@"Found end of child");

        [appDelegate.children addObject:aChild];

        aChild = nil;
    }

    else if([elementName isEqualToString:@"a:Key"])
    {
        NSLog(@"Found key");
    }

    else if([elementName isEqualToString:@"b:CheckedIn"])
    {
        NSLog(@"Found checkedIn");
    }

    else if([elementName isEqualToString:@"b:FirstName"])
    {
        NSLog(@"Found firstname");
    }

    else if([elementName isEqualToString:@"b:Gender"])
    {
        NSLog(@"found gender");
    }

    else if([elementName isEqualToString:@"b:Id"])
    {
        NSLog(@"found id");
    }

    else if([elementName isEqualToString:@"b:IsOnTour"])
    {
        NSLog(@"found isontour");

    }

    else if([elementName isEqualToString:@"b:LastName"])
    {
        NSLog(@"found lastname");
    }

    else if([elementName isEqualToString:@"b:GroupName"])
    {
        NSLog(@"found groupname");
    }

    currentElementValue = nil;

}
@end

Right now I’m just trying to see if it finds the data… then I will save it afterwards…
But in my didEndElement, it doesn’t seem to find anything other than

if([elementName isEqualToString:@"GetKidsResult"])

An example of my xml response:

            <a:KeyValueOfintKidf4KEWLbb>
            <a:Key>XXXXXXXX</a:Key>
            <a:Value xmlns:b="http://schemas.datacontract.org/2004/07/DayCare.DB.DTO">
                <b:CheckedIn>false</b:CheckedIn>
                <b:FirstName>XXXXXXX</b:FirstName>
                <b:Gender>Male</b:Gender>
                <b:Id>XXXXXXXX</b:Id>
                <b:IsOnTour>false</b:IsOnTour>
                <b:LastName>XXXXXX</b:LastName>
                <b:Photo>XXXXXXXX</b:Photo>
                <b:GroupName>XXXXX</b:GroupName>
            </a:Value>
        </a:KeyValueOfintKidf4KEWLbb>

Any idea as to why it doesn’t the other elements?
I’ve never done web services and such before, so the more simple the explanation, the better…

When I NSLog the element, I can see that it goes through the xml document properly

NSLog(@"Processing Element: %@", elementName);

Example:

Processing Element: a:KeyValueOfintKidf4KEWLbb
Processing Element: a:Key
Processing Element: a:Value
Processing Element: b:CheckedIn
Processing Element: b:FirstName
Processing Element: b:Gender
Processing Element: b:Id
Processing Element: b:IsOnTour
Processing Element: b:LastName
Processing Element: b:Photo
Processing Element: b:GroupName
  • 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-29T05:08:42+00:00Added an answer on May 29, 2026 at 5:08 am

    In didEndElement, try changing this part:

    if([elementName isEqualToString:@"GetKidsResult"])
    
        NSLog(@"end of xml");
        return;  
    

    to:

    if([elementName isEqualToString:@"GetKidsResult"])
    {
        NSLog(@"end of xml");
        return;  
    }
    

    Without putting those two statements after the if in a block, the return gets executed every time.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from

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.