3

I am using NSXMLParser to parse my data obatained from my webservice. But when I get the data from the server.

It gives me Error Code 5.

I am not able to see the response that comes from the webservice.

I use

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

But I cannot see the response in console when I write NSLog(@"%@",parser);

How can I display the response obtained from my webservice?

Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216

2 Answers2

6

Data returned from a URL is usually just text. It may also be XML, but you can see the raw response by 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);
}
e.James
  • 116,942
  • 41
  • 177
  • 214
0

With the error code 5 means , your xml was not well formed.
Ans as far as your xml output concerned , you had to implement the nsxmlparserdelegate methods to get the xml parsed check the tutorials on the same topic..

Aman Aggarwal
  • 3,754
  • 1
  • 19
  • 26