Note that there are some explanatory texts on larger screens.

plurals
  1. POError code 5 in application
    text
    copied!<p>I have developed one application to fetch RSS feed. I am getting this error code 5 for some URLs where as som others are working fine.</p> <p>I know this error means the xml is invalid. But for my app, I have not written any xml files by my own.</p> <p>Please tell me the probable reasons for this and let me know the solution</p> <h1>import "RootViewController.h"</h1> <p>@implementation RootViewController</p> <ul> <li>(void)viewDidAppear:(BOOL)animated{</li> </ul> <p>[super viewDidAppear:animated];</p> <p>if ([stories count] == 0) {</p> <pre><code> path = @"http://172.19.58.108:8080/jwplayer/JSP/Videolist.jsp"; [self parseXMLFileAtURL:path]; } </code></pre> <p>}</p> <p>-(void)parseXMLFileAtURL:(NSString *)URL{</p> <pre><code>stories = [[NSMutableArray alloc]init]; NSURL *xmlURL = [NSURL URLWithString:URL]; rssParser = [[NSXMLParser alloc]initWithContentsOfURL:xmlURL]; [rssParser setDelegate:self]; [rssParser setShouldProcessNamespaces:NO]; [rssParser setShouldReportNamespacePrefixes:NO]; [rssParser setShouldResolveExternalEntities:NO]; [rssParser parse]; </code></pre> <p>}</p> <p>-(void)parserDidStartDocument:(NSXMLParser *)parser{</p> <pre><code>NSLog(@"Found file and started parsing"); </code></pre> <p>}</p> <p>-(void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError{</p> <pre><code>NSString *errorString = [NSString stringWithFormat:@"Unable to download story feed from website (Error Code %i)", [parseError code]]; NSLog(@"Error parsing xml: %@", errorString); UIAlertView *errorAlert = [[UIAlertView alloc]initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [errorAlert show]; </code></pre> <p>}</p> <p>-(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{</p> <pre><code>currentElement = [elementName copy]; if ([elementName isEqualToString:@"item"]) { item = [[NSMutableDictionary alloc]init]; currentTitle = [[NSMutableString alloc]init]; currentDate = [[NSMutableString alloc]init]; currentSummary = [[NSMutableString alloc]init]; currentLink = [[NSMutableString alloc]init]; } </code></pre> <p>}</p> <p>-(void)parser: (NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{</p> <pre><code>if ([elementName isEqualToString:@"item"]) { [item setObject:currentTitle forKey:@"title"]; [item setObject:currentDate forKey:@"date"]; [item setObject:currentSummary forKey:@"summary"]; [item setObject:currentLink forKey:@"link"]; [stories addObject:[item copy]]; NSLog(@"adding story: %@", currentTitle); } </code></pre> <p>}</p> <p>-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{</p> <pre><code>if ([currentElement isEqualToString:@"title"]) { [currentTitle appendString:string]; } else if ([currentElement isEqualToString:@"link"]) { [currentLink appendString:string]; } else if ([currentElement isEqualToString:@"description"]) { [currentSummary appendString:string]; } else if ([currentElement isEqualToString:@"pubDate"]) { [currentDate appendString:string]; } </code></pre> <p>}</p> <p>-(void)parserDidEndDocument:(NSXMLParser *)parser{</p> <pre><code>[activityIndicator stopAnimating]; [activityIndicator removeFromSuperview]; NSLog(@"all done"); NSLog(@"stories array has %d items", [stories count]); [newsTable reloadData]; </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload