Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

carlosbutler

macrumors 6502a
Original poster
Feb 24, 2008
691
2
I am using a web service to get return an XML file. I have got the XML returned and is loaded on the phone, the information I need is displayed in the NSLog correctly and I can adapt the output to what I need.

BUT...

I am having trouble getting the information in to a table view. This is the first time using a webservice since I see more future potential for what I need my app to do (and in the future...).

I have included below the 'main' three parser methods (from what I have read up from today)
Code:
// Parser for the information being downloaded from the XML
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {	
	if ([elementName isEqualToString:@"Line"]) {
		if (!soapResults) {
			soapResults = [[NSMutableString alloc] init];
		}
		NSString *lineName = [attributeDict objectForKey:@"Name"];
		if (lineName) {
			[soapResults appendString:lineName];
			[soapResults appendString:@", "];
			[listOfLines addObject:[lineName copy]];
		}
	}
	if ([elementName isEqualToString:@"Status"]) {
		NSString *lineDescription = [attributeDict objectForKey:@"Description"];
		if (lineDescription) {
			[soapResults appendString:lineDescription];
		}
	}
}

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

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
	if ([elementName isEqualToString:@"Status"]) {
		NSString *tempString = soapResults;
		NSLog(@"Temp String: %@\n", tempString);
		
		
		//[listOfLines addObject:soapResults];
		//[listOfLines addObject:@"Hello"];
		//[self addToTable:tempString];
		
		
		NSLog(@"Soap Results: %@\n", soapResults);
		[soapResults setString:@""];
	}
}

Just to let you know, the XML layout for these parts is:
Code:
<Line ID="" Name="" />
    <Status ID="" CssClass="" Description="" IsActive="">
      <StatusType ID="" Description="" />
    </Status>

I am not sure if the three parser methods are called many times, or once... and the biggest issue is that I cannot seem to add any object to the NSMutableArray

I am not sure if this explained clearly enough, although any help would be great. I do certainly like the sound of webservices :)
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.