views:

93

answers:

2

I'm parsing an xml from an url, by

 rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
[rssParser parse]

How to NSLog it so as to see the xml in console??? If i use

NSLog ("%@",rssParser);

i'm showed wit 'XMLParser x 4d562' in the console

+1  A: 

You should set parser's delegate and process retrieved xml data in its methods. See NSXMLParserDelegate protocol reference.

Vladimir
+1  A: 

You can't. The NSXMLParser class never loads the entire contents of the XML stream in memory at once (that's why it's an "NSXMLParser" and not an "NSXMLDocument"). You should download the data from the URL, and use it to instantiate your RSS parser, and also to create an NSString that you log instead:

NSData *data = [NSData dataWithContentsOfURL:xmlURL];
rssParser = [[NSXMLParser alloc] initWithData:data];
NSString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSLog(@"data: %@", string);
[string release];

Please pay attention to the fact that the "initWithContentsOfURL:" methods are synchronous, and will block your UI thread until the data has downloaded. You might want to use ASIHTTPRequest or the NSURLConnection mechanism instead, with asynchronous connections.

Adrian Kosmaczewski