Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing with NSXMLParser issue
    primarykey
    data
    text
    <p>I'm trying to parse the response from a web server.</p> <p>My parser does as follows:</p> <pre><code>#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 </code></pre> <p>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</p> <pre><code>if([elementName isEqualToString:@"GetKidsResult"]) </code></pre> <p>An example of my xml response:</p> <pre><code> &lt;a:KeyValueOfintKidf4KEWLbb&gt; &lt;a:Key&gt;XXXXXXXX&lt;/a:Key&gt; &lt;a:Value xmlns:b="http://schemas.datacontract.org/2004/07/DayCare.DB.DTO"&gt; &lt;b:CheckedIn&gt;false&lt;/b:CheckedIn&gt; &lt;b:FirstName&gt;XXXXXXX&lt;/b:FirstName&gt; &lt;b:Gender&gt;Male&lt;/b:Gender&gt; &lt;b:Id&gt;XXXXXXXX&lt;/b:Id&gt; &lt;b:IsOnTour&gt;false&lt;/b:IsOnTour&gt; &lt;b:LastName&gt;XXXXXX&lt;/b:LastName&gt; &lt;b:Photo&gt;XXXXXXXX&lt;/b:Photo&gt; &lt;b:GroupName&gt;XXXXX&lt;/b:GroupName&gt; &lt;/a:Value&gt; &lt;/a:KeyValueOfintKidf4KEWLbb&gt; </code></pre> <p>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...</p> <p>When I NSLog the element, I can see that it goes through the xml document properly</p> <pre><code>NSLog(@"Processing Element: %@", elementName); </code></pre> <p>Example:</p> <pre><code>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 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload