NSXMLParser: how to display the response received from webservice?

I use NSXMLParser to analyze my data retrieved from my web service. But when I get data from the server.

He gives me error code 5.

I can not see the answer that comes from the web service.

I use

 NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:theURL];

But I do not see the answer in the console when I write NSLog(@"%@",parser);

How can I display the response received from my web service?

+3
source share
2 answers

The data returned from the URL is usually just text. It can also be XML, but you can see the original answer using the following:

NSError *error = nil;
NSString *string = [[NSString alloc] initWithContentsOfURL:theURL
                                                  encoding:NSUTF8StringEncoding
                                                     error:&error];
if (error != nil)
{
    NSLog(@"error: %@", error);
}
else
{
    NSLog(@"response: %@", string);
}
+6
source

5 , xml .
XML-, nsxmlparserdelegate, xml .

0

All Articles