0

This is a continuation of my previous question;

Parse/Display XML from a POST Method

And it worked, but what the answer didnt say was how to display the parsed xml onto a button like what I want.

I have a HTTP POST method that calls on the User's Lat & Lon to get a response on what suburb their in, and it posts and recieves fine and I just display the XML response to a label to see if it works and it does but, I want to display the parsed XML on a button, in particular only one of the categories that the response gives.

Here is my code

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

element = elementName;

if ([element isEqualToString:@"geocode"]) {

    geocode    = [[NSMutableDictionary alloc] init];
    state   = [[NSMutableString alloc] init];
    suburb    = [[NSMutableString alloc] init];
}}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {

if ([element isEqualToString:@"state"]) {
    [state appendString:string];
} else if ([element isEqualToString:@"suburb"]) {
    [suburb appendString:string];
}}
  - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
if ([elementName isEqualToString:@"geocode"]) {
    [geocode setObject:state forKey:@"state"];
    [geocode setObject:suburb forKey:@"suburb"];
}}

And I use this part of the parser

parser = [[NSXMLParser alloc] initWithData:urlData];
           [parser setDelegate:self];
           [parser setShouldResolveExternalEntities:NO];
           [parser parse];
Community
  • 1
  • 1

1 Answers1

0

When you parse an XML, you insert object of response in an array or in a variable..Next, you show she info contained in the variable or array where you want.

Matteo Gobbi
  • 17,697
  • 3
  • 27
  • 41