tags:

views:

46

answers:

1

i can only parse 1st element of this xml but i want to get all the content of cuisine this is my xml

<cuisines>
<cuisine>Asian</cuisine>
<cuisine>Nepalese</cuisine>
<cuisine>North Indian</cuisine>
<cuisine>Indian Vegetarian</cuisine>
<cuisine>Organic Cuisine</cuisine>
</cuisines>

and this is the code to parse

if ( [elementName isEqualToString:@"cuisines"]) {


        if ( [elementName isEqualToString:@"cuisine"] ) {



            elementName=[[NSMutableString alloc] init];

            keyInProgress = [elementName copy];

            // This is a string we will append to as the text arrives
            textInProgress = [[[NSMutableString alloc] init]autorelease];

            return;
        }

but its not working i want to get all the value

A: 

you need to implement the parser method as well as the following NSXMLParserDelegate protocol methods methods:

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

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

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

A good tutorial can be found here: Consuming a RESTful Service (bit.ly) in an iPhone Application

ennuikiller